app.example.io) is automatically authenticated on other subdomains (e.g. marketplace.example.io, shop.example.io) that share the same parent domain and Dynamic environment.
Why use it
- Reduced XSS risk — the token is not accessible to JavaScript.
- Session hijacking mitigation — HttpOnly cookies cannot be extracted by client-side scripts.
- Cross-subdomain sessions — one sign-in covers all subdomains under the same parent domain.
How it works
Dynamic requires a custom hostname — a subdomain you own, pointed by DNS CNAME to Dynamic’s API. This lets Dynamic’s backend set a first-party, secure HttpOnly cookie on your domain. For example, if your site ishttps://app.example.io, you could configure https://auth.example.io as the custom hostname. When a user signs in on app.example.io, Dynamic sets an HttpOnly cookie for .example.io. That cookie is then sent by the browser on any subdomain ending with .example.io.
Setup
1. Create a cookie domain
Go to the Dynamic dashboard, expand Developer, and select Domains. Create a new cookie domain. Provide a subdomain you own. We recommend prefixing withauth — for example, auth.example.io for the domain example.io.
2. Configure DNS
Follow the instructions in the dashboard. You will need three DNS records:- 2 TXT records — for site and certificate verification.
- 1 CNAME record — to proxy the custom subdomain to Dynamic.
In
sandbox, Dynamic also attempts to set the cookie from the SDK frontend to support local development and preview environments.3. Update your SDK configuration
Once DNS is validated, configure your SDK to use the custom hostname as the API base URL. See the SDK-specific guide for your platform:React
React Native
JavaScript
4. Enable cookie-based authentication
Go to Account Security in the dashboard and enable the cookie-based authentication toggle. The cookie is stored asDYNAMIC_JWT_TOKEN in your browser’s cookies. It contains the minified Dynamic JWT.
Verifying your cookie configuration
Before going live, verify your domain and cookie setup.Domain configuration
The domain must be set in both your sandbox and live environments. The domain you configure must match the verified domain associated with your Dynamic environment — partial or mismatched domains cause cookie-setting to silently fail.Testing locally
For local development, test against the sandbox environment. Dynamic includes the JWT in the response header (via localStorage) in sandbox so you can inspect tokens without a valid cookie domain.The localStorage fallback for JWTs is only available in sandbox. It is not used in production.
Pre-launch checklist
Verify your domain
Confirm the domain is set in both your sandbox and live environments in the Dynamic dashboard.
Test on a staging domain
Run the full cookie authentication flow on a staging environment with a valid, resolvable domain — not localhost.
Confirm cookie is set
Check that the JWT is delivered as a cookie and is not falling back to localStorage.