> ## 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 dashboard setup steps, see [Cookie-based authentication](/overview/authentication/cookie-authentication).

## SDK configuration

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

Once your [cookie domain](/overview/authentication/cookie-authentication#setup) is configured and DNS is validated, pass `apiBaseUrl` when creating the client to point to your custom hostname:

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

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

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