Skip to main content
Use this page for embedded runtime implementation details after you choose embedded auth as your integration pattern. For authentication pattern selection across embedded, standalone, and API auth, use Authentication. For parameter-by-parameter definitions, defaults, and validation rules, use Configuration reference.
Need brand alignment? Use Configuration reference to customise font and theme colours from your host app.

What you need before you embed

Frontend host page

A page in your tenant application where you can load the SDK script and render a mount container.

Backend token route

A backend endpoint that can mint short-lived Embed Tokens for the currently authenticated tenant user.

Connected App setup

A provisioned Connected App with a client id and secret that match the token-signing configuration on your backend.

Scope of this guide

This guide only covers embedded Narrative SDK boot and runtime decisions.

Required configuration

The full field-level reference for these values lives in Configuration reference.
1

Load the SDK loader

Loader script
2

Add a widget container

3

Fetch and set Embed Token

Browser

Runtime decisions

Fetch it only after the tenant app has already established its own authenticated user session. The Embed Token should represent the current tenant user, not an anonymous browser session.
Use declarative boot when you have a stable host page and container. Use imperative boot when your application needs to control mount timing, page transitions, or cleanup explicitly.
Keep it short-lived. The current guidance is 5-15 minutes, with iat and exp expressed in Unix seconds.
It must be JWT + HS256, use aud = nsdk-embed, include the required claims (iss, sub, aud, iat, exp, jti), and include nsdk.user.name plus nsdk.user.email.

Minimal implementation flow

Security checklist

Keep connected app secrets server-side only. Do not expose token signing logic in browser code.

No browser signing

Never expose the Connected App secret or JWT signing logic to frontend code.

Short-lived token handoff

Do not store Embed Tokens in browser local storage. Treat them as short-lived bootstrap credentials.

Transport and access controls

Use HTTPS, strict origin or CSP controls, and validate tenant user authorisation before minting each token.

Optional imperative mode

Browser

Validation and troubleshooting

Check that the container exists before boot, data-nsdk="true" is present for declarative mode, and the token has been set on the container before the SDK initializes.
Recheck iss, aud, iat, exp, and the HS256 signing secret. Audience mismatches and milliseconds-vs-seconds timestamps are the most common causes.
Prefer a same-origin token endpoint. If that is not possible, configure CORS explicitly for the tenant frontend origin and any required credentials flow.
Use Configuration reference for field-by-field definitions and Authentication for token and session lifecycle behaviour.
For the complete troubleshooting guide covering all common integration issues, see Troubleshooting. For common questions, see FAQ.