# Environment variables

Learn how to configure the SDK using environment variables.

Environment variables provide a flexible way to configure the Croct SDK in your Hydrogen project. The Croct [Vite plugin](/reference/sdk/hydrogen/api/setup/vite-plugin) reads them and bakes the public values into the browser bundle.

Here is a basic example that enables debug mode:

**.env**

```bash
PUBLIC_CROCT_APP_ID=00000000-0000-0000-0000-000000000000
PUBLIC_CROCT_DEBUG=true
```

## Variables

Here is a list of all available environment variables:

- `PUBLIC_CROCT_APP_ID`: `string`

  The Application ID in the form of a UUID.

  You can find this ID on the [Integration page](https://app.croct.com/redirect/organizations/-organization-/workspaces/-workspace-/applications/-application-/integration) of your application.

- `CROCT_API_KEY`: `string`

  The [API key](/explanation/application/api-keys) used to authenticate requests.

  To generate an API key, go to the [API keys page](https://app.croct.com/redirect/organizations/-organization-/workspaces/-workspace-/applications/-application-/keys) of your application and make sure to grant the **Issue user tokens** permission.

- `PUBLIC_CROCT_DEBUG`: `boolean` (optional) (default: false)

  Whether to enable [debug mode](/reference/sdk/hydrogen/troubleshooting/debugging).

  When enabled, the SDK logs additional information to the console to help you debug your application.

- `PUBLIC_CROCT_TEST`: `boolean` (optional) (default: false)

  Whether to enable [test mode](/reference/sdk/hydrogen/testing/unit-testing).

  When enabled, the SDK uses a mock event transport layer to simulate successful transmission, which is useful for testing.

- `PUBLIC_CROCT_TRACK`: `string` (optional) (default: auto)

  The automatic event tracking mode.

  The following values are supported:

  | Mode     | Description                                                                                                                                         |
  | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `auto`   | Tracking follows Shopify's [Customer Privacy](https://shopify.dev/docs/api/customer-privacy) consent, staying disabled until the visitor allows it. |
  | `always` | Tracking runs unconditionally, regardless of consent.                                                                                               |
  | `never`  | Automatic tracking is disabled, leaving the SDK available for manual tracking.                                                                      |

- `PUBLIC_CROCT_BASE_ENDPOINT_URL`: `string` (optional) (default: https\://api.croct.io)

  The base URL for API calls.

  This variable lets you override the default API base URL, which is useful for testing purposes.

  See [Integration testing](/reference/sdk/hydrogen/testing/integration-testing) for more information.

- `CROCT_DISABLE_USER_TOKEN_AUTHENTICATION`: `boolean` (optional) (default: false)

  Whether to disable token-based user authentication.

  By default, the SDK uses [tokens](/explanation/application/signed-tokens) to authenticate users for enhanced security.

- `CROCT_TOKEN_DURATION`: `number` (optional) (default: 86400)

  The duration of the user token in seconds.

  This value determines how long the user token is valid before the SDK generates a new token.

  By default, the token is valid for 24 hours.

- `PUBLIC_CROCT_DEFAULT_FETCH_TIMEOUT`: `number` (optional) (default: 2000)

  The default timeout for fetch requests in milliseconds.

  This value determines how long the SDK waits for a response before timing out.

  The default timeout is 2 seconds.

- `PUBLIC_CROCT_DEFAULT_PREFERRED_LOCALE`: `string` (optional)

  The default preferred locale for fetching content, like `en-us` or `pt-br`.

  This value determines the default locale used by the SDK when no locale is specified.

- `PUBLIC_CROCT_CLIENT_ID_COOKIE_NAME`: `string` (optional) (default: ct.client\_id)

  The name of the cookie that stores the Client ID.

- `PUBLIC_CROCT_CLIENT_ID_COOKIE_DURATION`: `number` (optional) (default: 31536000)

  The duration of the Client ID cookie in seconds.

  This value determines how long the browser will keep the Client ID cookie. The lifetime is extended with each visit to the site.

  The default is 1 year.

- `PUBLIC_CROCT_CLIENT_ID_COOKIE_DOMAIN`: `string` (optional)

  The domain of the Client ID cookie.

  This is useful when you have a website with multiple subdomains, like `shop.example.com` and `blog.example.com`, and you want to recognize the same user across all of them.

  For more information, see the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#define_where_cookies_are_sent).

- `PUBLIC_CROCT_USER_TOKEN_COOKIE_NAME`: `string` (optional) (default: ct.user\_token)

  The name of the cookie that stores the user token.

- `PUBLIC_CROCT_USER_TOKEN_COOKIE_DURATION`: `number` (optional) (default: 604800)

  The duration of the user token cookie in seconds.

  This value determines how long the browser will keep the user token cookie. The lifetime is extended with each visit to the site.

  The default is 7 days.

- `PUBLIC_CROCT_USER_TOKEN_COOKIE_DOMAIN`: `string` (optional)

  The domain of the user token cookie.

  This is useful when you have a website with multiple subdomains, like `shop.example.com` and `blog.example.com`, and you want to recognize the same user across all of them.

  For more information, see the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#domain_attribute).

- `PUBLIC_CROCT_PREVIEW_TOKEN_COOKIE_NAME`: `string` (optional) (default: ct.preview\_token)

  The name of the cookie that stores the preview token.

- `PUBLIC_CROCT_PREVIEW_TOKEN_COOKIE_DOMAIN`: `string` (optional)

  The domain of the preview token cookie.

  This is useful when you have a website with multiple subdomains, like `shop.example.com` and `blog.example.com`, and you want the preview to work across them.

  For more information, see the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#domain_attribute).
