> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Cookie-based authentication

> Configure the JavaScript SDK to use cookie-based authentication with a custom API base URL.

For what cookie-based authentication is, how it works, and full console setup steps, see [Cookie-based authentication](https://docs.dynamic.xyz/docs/auth/cookie-authentication.md).

## SDK configuration

Before this: create and initialize a Dynamic client (see [Creating a Dynamic Client](https://docs.dynamic.xyz/docs/javascript/reference/client/create-dynamic-client.md), [Initializing the Dynamic Client](https://docs.dynamic.xyz/docs/javascript/reference/client/initialize-dynamic-client.md)).

Once your [cookie domain](https://docs.dynamic.xyz/docs/auth/cookie-authentication.md#setup) is configured and DNS is validated, pass `apiBaseUrl` in `createDynamicClient()`'s `coreConfig` to point to your custom hostname:

```javascript theme={"system"}
import { createDynamicClient } from '@dynamic-labs-sdk/client';

const dynamicClient = createDynamicClient({
  environmentId: 'YOUR_ENVIRONMENT_ID',
  coreConfig: {
    apiBaseUrl: 'https://auth.example.io/api/v0',
  },
});
```

Replace `auth.example.io` with the custom hostname you configured in the Dynamic Console.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.