Sample partner app
The public Paprel Embed examples repository contains a production-shaped, framework-neutral real-estate application. It mounts @paprel/embed-accounting and @paprel/embed-reports as real npm consumers and demonstrates the boundaries your host application should own.
Run locally
git clone https://github.com/nexara-global/paprel-embed-ui-examples.git
cd paprel-embed-ui-examples
npm install
cp apps/real-estate-accounting/.env.example apps/real-estate-accounting/.env.local
npm run dev
Open http://127.0.0.1:5181/. Without App Connect credentials, the application still starts and shows the exact server variables required for the selected entity.
The sample includes:
- A local-only
/api/embed-tokenBFF that exchanges App Connect credentials - Host-owned routing, company context, URL-backed search, filters, tabs, and pagination
- Delegated
paprel:resource-open,paprel:view-change, andpaprel:operation-successevents - Account, journal, bank, transaction, reconciliation, lock, and report routes
- One App Connect client per managed company, with tokens cached per company in the BFF
- Inherited Paprel design tokens inside a partner-owned shell
Authentication is App Connect client credentials only. The sample does not use Partner API sessions.
Three details worth copying
These are the parts a host application usually gets wrong, so the sample is built to show them working:
Renewing a token must not remount your widgets. The sample re-renders only what changed, so a token renewal, a Refresh, or a list URL update leaves unsaved journal and account form values, focus, and scroll position intact. If your host rebuilds the route on every session change, an operator loses a half-typed journal every hour.
One token request per connect. The token route is rate limited per client IP, and every user of your product shares your server's IP. The sample's BFF caches each company's token until it nears expiry, so a reconnect does not exchange credentials twice.
An expired session is recoverable in place. When the token cannot be renewed, the sample shows a banner with a Reconnect button and keeps the page mounted, rather than redirecting away from unsaved work.
Pass criteria
Before porting the pattern into your stack, confirm:
- Chart of accounts loads without console errors
- Journal list loads and pagination works
- Row click opens journal detail
- Editor saves a balanced journal and the host displays success feedback
- Banking, reconciliation, and report routes load with the required scopes
- Browser history restores list filters and pagination
- A journal form keeps a typed-in value across a token renewal
- Expiring a session shows the Reconnect banner, and reconnecting returns to the same view
- The journal and account forms use the company's currency, not a hardcoded one
Environment
Copy .env.example to .env.local. A new setup starts with one company, and the file carries a commented template for adding a second:
| Variable | Side | Purpose |
|---|---|---|
VITE_PAPREL_API_BASE_URL | Browser | Sandbox or production API base URL |
VITE_PARTNER_DOMAIN | Browser | Your registered partner domain |
VITE_PAPREL_ENTITIES | Browser | Companies in the sidebar switcher, as key:Display name. The first entry must use the key default |
APP_CONNECT_TOKEN_URL | Server | App Connect token endpoint |
APP_CONNECT_CLIENT_ID | Server | Client id for the default company |
APP_CONNECT_CLIENT_SECRET | Server | Client secret — never in a VITE_* variable |
PARTNER_DOMAIN | Server | Partner domain sent with the token exchange |
An "entity" in this sample is one company in your product, and each has its own App Connect client. To add a second, append it to VITE_PAPREL_ENTITIES and set APP_CONNECT_ENTITY_<KEY>_CLIENT_ID and _CLIENT_SECRET; the token URL and partner domain fall back to the values above.
The proxy verifies TLS. It skips verification only for local hosts, or when you set PAPREL_DEV_INSECURE_TLS=1 for an untrusted local certificate — never in production.
The Vite BFF is for local development only. A production route must authenticate and authorize the partner user before choosing a company or minting a token.