Skip to main content

React Component Integration

Planned

The React component is not available yet. This page describes the planned design so you can decide which option fits your product. To be notified when it is available, or to join early access, contact your SwyftFilings contact.

For a production integration today, use the Iframe integration.

The React component will render the Customer Portal inside your React application. Compared with the iframe, it will give you typed props, event callbacks and per-render theming. It will use the same Customer Portal access token and the same branding and sections.

Planned usage​

import { SwyftFilingsPortal } from "@swyftfilings/portal-react";

function MyFilings({ portalToken, partnerId }: { portalToken: string; partnerId: number }) {
return (
<SwyftFilingsPortal
token={portalToken}
partnerId={partnerId}
initialPage="/my-orders"
theme={{ primary: "#5B3FD9", background: "#F8F7FC", text: "#1C1535" }}
onNavigate={(page) => console.log("Portal page:", page)}
onSessionExpired={() => refreshPortalToken()}
onError={(error) => console.error(error)}
/>
);
}

As with the iframe, your server requests token and partnerId from GET /tokens/{email}/ucp, and passes them to the page.

Planned props​

PropTypeDescription
tokenstringCustomer Portal token. Required.
partnerIdnumberpartner_id from the token response. Required.
initialPagestringSection to open first, for example /my-documents. Defaults to /.
theme{ primary?, background?, text? }Color overrides on top of your partner branding.
onNavigate(page: string) => voidCalled on each page change. It replaces listening for PORTAL_NAVIGATION messages.
onSessionExpired() => voidCalled when the session ends. Request a new token and re-render.
onError(error: Error) => voidCalled when the portal can't load or sign the customer in.
className, styleStyling for the outer container.

Iframe or React component?​

IframeReact component (planned)
Works withAny websiteReact 18+ apps
SetupOne iframe plus a token requestnpm package plus a token request
BrandingPartner brandingPartner branding plus per-render color overrides
EventspostMessage (PORTAL_NAVIGATION)Typed callbacks
Session expiryDetect /login navigation, then reload with a new tokenonSessionExpired callback
AvailabilityAvailablePlanned