Instances / Environments
When creating a new application within Clerk, you are provided with two instances: Development
and Production
. These instances vary slightly and should only be used appropriately.
Development instance
A Development
instance is Clerk's default instance type and has characteristics that allow it to be more useful for local development. To facilitate development and local authentication, Development
instances have a more relaxed security posture and are not suitable for production workloads.
Some notable examples of Development
-only characteristics in a Clerk application are:
- A
Development
banner is shown prominently in the Clerk Dashboard to make clear you're managing or configuring non-production data - Email and SMS templates are prefixed with the environment type to prevent against using
Development
instances for production purposes - Some social connections use shared credentials by default
- The Account Portal will use a Clerk development domain that ends with
accounts.dev
instead of your app's production domain - OAuth consent screens will show the development domain that ends with
accounts.dev
instead of your production domain - Search engines will not be able to crawl and index your application
- Development instances have a 100 users cap and user data can not be transferred between instances
Production instance
A Production
instance is the more robust option of Clerk's instance types. Production
instances are meant to support high volumes of traffic and by default, have a more strict security posture.
Some notable differences between Production
and Development
instances in a Clerk application are:
- You must associate a production domain within the Clerk Dashboard
- You are required to provision your own SSO credentials
When deploying to production, you must first activate your Production
environment. See the Deploying to Production guide to learn about the process and avoid common pitfalls.
Staging environments
Staging environments enable you to internally test and demo changes to your application or website before deploying them to production. Currently, Clerk only offers Development and Production instances. Official support for Staging instances is still on the roadmap. However, you can set up a "staging environment" by creating a separate Clerk application with a separate domain.
Creating a separate Clerk application will prevent you from using live production environment data in your staging environment. If you are on a Pro, Enterprise, or Startup plan, Clerk will fully upgrade your staging application for free.
It is important to note that when you use a separate Clerk application for your staging environment, changes to this application will not be automatically mirrored in your main application for your production environment. You must manually make these changes yourself if you want them to be reflected in both applications.
Set up a staging Clerk application
The following steps will help you set up a new Clerk application with a staging-specific domain:
- Set up a subdomain - This will be your staging domain. For example, if your domain is
my-site.com
, you could usestaging.my-site.com
. - Create a new Clerk app - Your staging environment will connect to this app instead of your main one. See the Clerk quickstart guide to learn how to create a Clerk app.
- Deploy and configure your staging app's production instance - Using production API keys will make your staging app more secure. Follow the Deploy to production guide to do so.
- Contact Clerk support to upgrade your staging app for free - If you are on a Pro, Enterprise, or Startup plan, Clerk will fully upgrade your staging app for free.
Alternatives
Preview environments
While staging environments are typically long-lived, preview environments are typically generated on-demand for specific pull requests. See the section on using Clerk in a preview environment to learn about your options.
Shared production credentials
If you would like to share settings and data between your production and staging environments, see the dedicated guide. This is not recommended because you will be sharing a user table between your production and staging environments.
Preview environments
Some popular hosting providers like Vercel and Netlify offer preview deployments, which enable you to view changes to your site in a live environment before merging and deploying them to production.
There are two high-level approaches to using Clerk in a preview environment:
- Sharing production settings and user data
- Using independent settings and user data
Sharing production settings and user data
To share production settings and user data with your preview environment, your preview environment must be hosted on the same root domain (but a separate subdomain) as your production application. The preview environment must also be configured to use the same API keys as your production environment.
Generally, hosts have a special feature to host the preview environment on a subdomain of your root domain, for example:
- Vercel: use the Preview Deployment Suffix feature. This feature is only available on Vercel's Pro and Enterprise plans.
- Netlify: use the Automatic Deploy Subdomain feature.
Using independent settings and user data
There are two approaches to creating a preview environment with independent settings and user data:
- Easiest: Use your host's provided preview domain, like *.vercel.app or *.netlify.app, with development API keys from Clerk.
- Acquire an additional root domain for your preview environment, completely separate from your production application's root domain.
Use your host's provided preview domain
Configure the preview environment to use development API keys from Clerk. It is currently not possible to use Clerk production API keys with your host's provided preview domain.
Acquire an additional root domain
To use an additional root domain, you must first configure your host to deploy preview environments to that domain:
- Vercel: use the Preview Deployment Suffix feature. This feature is only available on Vercel's Pro and Enterprise plans.
- Netlify: use the Automatic Deploy Subdomain feature.
You can configure this environment with either your development API keys (recommended) or you can create an additional production instance and use those production API keys.
Feedback
Last updated on