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
| Prop | Type | Description |
|---|---|---|
token | string | Customer Portal token. Required. |
partnerId | number | partner_id from the token response. Required. |
initialPage | string | Section to open first, for example /my-documents. Defaults to /. |
theme | { primary?, background?, text? } | Color overrides on top of your partner branding. |
onNavigate | (page: string) => void | Called on each page change. It replaces listening for PORTAL_NAVIGATION messages. |
onSessionExpired | () => void | Called when the session ends. Request a new token and re-render. |
onError | (error: Error) => void | Called when the portal can't load or sign the customer in. |
className, style | Styling for the outer container. |
Iframe or React component?
| Iframe | React component (planned) | |
|---|---|---|
| Works with | Any website | React 18+ apps |
| Setup | One iframe plus a token request | npm package plus a token request |
| Branding | Partner branding | Partner branding plus per-render color overrides |
| Events | postMessage (PORTAL_NAVIGATION) | Typed callbacks |
| Session expiry | Detect /login navigation, then reload with a new token | onSessionExpired callback |
| Availability | Available | Planned |