Vercel Auth doesn’t just guard your deployments; it’s a sophisticated gatekeeper that can also control who can see and interact with your project’s development environments.

Let’s see this in action. Imagine you have a staging environment for your app that you want to keep private, accessible only to your team.

// vercel.json
{
  "github": {
    "enabled": true
  },
  "alias": [
    {
      "use": "@vercel/next",
      "config": {
        "domain": "staging.your-awesome-app.com"
      }
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "dest": "/index.html",
      "methods": ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"],
      "headers": {
        "x-vercel-auth": "1"
      }
    }
  ]
}

In this vercel.json snippet, the routes section is where the magic happens for Vercel Auth. Specifically, the "headers": { "x-vercel-auth": "1" } directive tells Vercel to protect this route. When a request hits staging.your-awesome-app.com, Vercel will check if the user is authenticated. If they are, Vercel will then check if that authenticated user has access to the project. If both conditions are met, the request proceeds. If either fails, the user is presented with a Vercel-hosted login screen.

The core problem Vercel Auth solves here is the secure exposure of sensitive environments. Without it, anyone who knew the staging URL could potentially access and interact with your work-in-progress code, leading to accidental data corruption, unwanted feedback, or even security vulnerabilities. Vercel Auth provides a unified, simple mechanism to prevent this, leveraging your existing Vercel account or team memberships.

Internally, when a request comes in for a protected route, Vercel checks for a valid session cookie. If one exists and is associated with an authenticated user, Vercel then queries its internal authorization system to see if that user has the necessary permissions for the specific project and environment. This is all handled transparently at the edge, meaning the request never even reaches your application’s server if authentication or authorization fails.

The exact levers you control are primarily within your Vercel project settings and the vercel.json configuration. You can specify which branches or environments should be protected. For instance, you might want to protect all deployments from your staging branch but leave your main branch public. This is typically managed through the Vercel dashboard under "Project Settings" > "Domains" or "Git Integrations," where you can define aliases and associate them with specific branches and authentication requirements.

The x-vercel-auth header is a signal, not the entirety of the mechanism. Vercel’s edge network intercepts requests matching protected routes based on your vercel.json configuration. It then initiates a flow that involves checking for a valid session token. If no token is present or it’s invalid, Vercel redirects the user to its authentication service. Upon successful authentication, Vercel verifies the user’s team and project membership. Only if these checks pass is the request forwarded to your deployment.

Beyond simple authentication, Vercel Auth integrates deeply with your team’s structure. You can grant access to specific individuals or entire teams, controlling who can view or deploy to particular environments. This granular control ensures that only authorized personnel can interact with staging, preview, or even production deployments, depending on your configuration.

The surprising truth is that Vercel Auth is not just about logging in; it’s a sophisticated access control layer that can dynamically gate your entire application’s frontend based on user identity and team membership, all before the request even hits your backend.

The next concept you’ll likely encounter is managing custom domains and SSL certificates for these authenticated deployments.

Want structured learning?

Take the full Vercel course →