Enabling cookies
In the React SDK you set the custom hostname through the provider’s settings. In the JavaScript SDK you passapiBaseUrl in createDynamicClient()’s coreConfig, pointing at the cookie domain you configured in the dashboard. The dashboard setup (creating the cookie domain and validating DNS) is identical.
dynamicClient to DynamicProvider as usual (see Basic setup) — the cookie configuration lives entirely on the client, so nothing else changes.
Accessing the token
In a cookie environment the JWT never reaches your app, sogetDefaultClient().token is always null — there is no bearer token to read or attach. Instead of reading the token, let the browser send the cookie automatically rather than adding an Authorization header yourself.
fetch’s credentials option defaults to same-origin, which already sends the cookie on requests to the same origin as your page. So if your authenticated endpoints are same-origin, you don’t need to set anything:
credentials: 'include' when the request is cross-origin — for example, your app is on app.example.io and the cookie domain is auth.example.io. Because the Dynamic cookie is SameSite=Lax, it still only rides on same-site requests (same registrable domain), and the server must opt in with Access-Control-Allow-Credentials: true and an explicit Access-Control-Allow-Origin (never *) — the browser won’t expose the response otherwise. Prefer keeping calls same-origin; reach for include only when you genuinely cross origins.
Errors you now own
See also
- Cookie-based authentication (concept & dashboard setup) — what it is and how to configure the domain
- Cookie-based authentication (JavaScript reference) — the SDK configuration reference
- Users — read the user and why
tokenisnull - Basic setup — creating and initializing the client