Environment variables
Discover the configuration available through environment variables.
Environment variables provide a flexible way to configure the Croct SDK in your Next.js project. You can define these variables either directly in your environment or in an .env file in the root of your project.
Here is a basic example that enables debug mode:
NEXT_PUBLIC_CROCT_APP_ID=00000000-0000-0000-0000-000000000000NEXT_PUBLIC_CROCT_DEBUG=true
See the official documentation for more information on how to use environment variables in Next.js.
Variables
Here is a list of all available environment variables:
- NEXT_PUBLIC_CROCT_APP_IDstring
The Application ID in the form of a UUID.
You can find this ID on the Integration page of your application.
- CROCT_API_KEYstring
The API key used to authenticate requests.
To generate an API key, go to the API keys page of your application and make sure to grant the Authentication permission.
- NEXT_PUBLIC_CROCT_DEBUG(optional)boolean
Whether to enable debug mode.
When enabled, the SDK logs additional information to the console to help you debug your application.
Default:false- NEXT_PUBLIC_CROCT_TEST(optional)boolean
Whether to enable test mode.
When enabled, the SDK uses a mock event transport layer to simulate successful transmission, which is useful for testing.
Default:false- NEXT_PUBLIC_CROCT_BASE_ENDPOINT_URL(optional)string
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 for more information.
Default:https://api.croct.io- CROCT_DISABLE_USER_TOKEN_AUTHENTICATION(optional)boolean
Whether to disable token-based user authentication.
By default, the SDK uses tokens to authenticate users for enhanced security.
Default:false- CROCT_TOKEN_DURATION(optional)number
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.
Default:86400- NEXT_PUBLIC_CROCT_DEFAULT_FETCH_TIMEOUT(optional)number
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.
Default:2000- NEXT_PUBLIC_CROCT_DEFAULT_PREFERRED_LOCALE(optional)string
The default preferred locale for fetching content, like en-us or pt-br.
Auto-configurationThe SDK auto-detects the preferred locale if you are using Internationalized Routing, so you only need to specify it if you are not using this feature.
This value determines the default locale used by the SDK when no locale is specified.
The name of the cookie that stores the Client ID.
Default:ct.client_idThe 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.
Default:31536000The domain of the Client ID cookie.
This variable determines on which domain(s) the user token cookie is accessible. 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.
The name of the cookie that stores the user token.
Default:ct.user_tokenThe 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.
Default:604800The domain of the user token cookie.
This value determines on which domain(s) the user token cookie is accessible. 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.
The name of the cookie that stores the preview token.
Default:ct.preview_tokenThe domain of the preview token cookie.
This value determines on which domain(s) the preview token cookie is accessible. 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.