Deploy React auth to Vercel in minutes

Email and password sign-up with a confirmation link, sign-in, and an account page with every active session, live on Vercel. Four console settings, one example app and one deploy.

Gleisson MatosFounder & CEO4 min read
On this page

This guide puts a React app with real authentication on Vercel. Nulvless handles the accounts, the confirmation email and the sessions. Vercel serves the app. You write no auth code: the app is the account center example, which you create with the Nulvless CLI.

By the end, anyone can open your vercel.app URL, sign up with email and password, confirm the account from the link in the email, sign in, and see every device they are signed in on.

Build this with your agent

A ready prompt for Claude Code, Cursor, ChatGPT or any coding agent. It points the agent at this guide and the docs, so it follows the real API instead of guessing.

Deploy the Nulvless account center example to Vercel.

Follow this page. It documents the real console settings and commands, so do not guess:
- https://www.nulvless.com/llms.mdx/blog/deploy-react-auth-to-vercel/content.md

Requirements:
- Create the app with `nulvless create my-app --example account-center-react`.
- Read the environment URL and publishable key from VITE_NULVLESS_URL and VITE_NULVLESS_KEY. Never use a secret key (sk-…) in this app.
- Add a vercel.json that rewrites every path to /index.html, so /activate and /account load on a direct visit.
- Set both variables in Vercel before the production build.

Before you start, ask me for the environment URL and publishable key, and remind me to set the confirmation URL and redirect URLs in the console after the first deploy.
or open in

What you need

  • A Nulvless project in the console.
  • A Vercel account.
  • Node.js 20 or later.

The settings below belong to one environment. Pick the environment this deployment will use, such as main for production, and make every change in it.

1. Set up sign-up and sign-in in the console

Open Authentication → Registration. Under Sign-ups:

  • Allow new users to sign up is on.
  • Required credentials: Email.
  • Confirmation type: Link.

Save. Every new account now gets an email with a link, and the account only works after the link is opened.

Sign-in: email and password

Open Authentication → Authentications. Under Authentication methods, choose Email and password for Email, and save.

The Passwords section on the same page sets the minimum length and the characters a password needs.

Create a public API key

Open API Keys and choose Create public key. Give it a name, such as vercel-web, and copy the key. It starts with pk-.

A public key is meant for the browser: it can only do what the signed-in user could already do. The private key (sk-…) never goes into this app.

Copy the environment URL

On the project Overview, copy the URL of the environment. It looks like https://<project>.nulvless.co.

2. Create the app

Install the CLI and create the app from the account center example:

npm install --global @nulvless/cli
nulvless create my-app --example account-center-react
cd my-app
npm install

It is a Vite app with React Router. The pages that matter here:

  • /sign-up and /sign-in. After sign-up, a confirmation link sends the user to /check-email.
  • /activate confirms the account from the link in the email.
  • /account lists the user's sessions and can end any of them.

The client reads two variables:

src/lib/nulvless.ts
import { createClient, Storage } from '@nulvless/nulvless-js';

export const nulvless = createClient(import.meta.env.VITE_NULVLESS_URL, import.meta.env.VITE_NULVLESS_KEY, {
  storage: Storage.Local,
  trackUser: true,
});

3. Let Vercel serve every route

The app routes in the browser. Opened directly, /activate?token=… from the email would answer 404 on Vercel, because no file exists at that path. Add a vercel.json at the root of the app that sends every path to index.html:

vercel.json
{
  "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}

4. Deploy

Install the Vercel CLI and link the folder to a new project. Vercel detects Vite, so accept the defaults:

npm install --global vercel
vercel link

Vite writes the variables into the bundle at build time, so add them before the production build:

vercel env add VITE_NULVLESS_URL production
vercel env add VITE_NULVLESS_KEY production

Paste the environment URL and the pk- key when asked. Then deploy:

vercel --prod

Vercel prints the production URL, such as https://my-app.vercel.app.

The account center example on Vercel: the sign-in page

Prefer Git? Push the folder to GitHub, import the repository in the Vercel dashboard, and add the same two variables under Environment Variables before the first deploy.

5. Point the console at your Vercel URL

Back in the console, open Redirect URLs in the project and use your Vercel URL:

  • Site URL: https://my-app.vercel.app
  • Confirmation URL: https://my-app.vercel.app/activate. This is where the link in the sign-up email leads.
  • Redirect URIs: add https://my-app.vercel.app. Redirects only go to the URLs listed here.

These are console settings, so they need no new deploy.

6. Try it

  1. Open https://my-app.vercel.app/sign-up and create an account.
  2. The app moves to /check-email. Open the email and choose the link: it opens /activate on your Vercel URL and confirms the account.
  3. Sign in. Then sign in again from another browser.
  4. Open Account: both sessions are listed, and the current one is marked This device. Choose Sign out on the other one, and that browser is signed out on its next request.
The Account page: account details, sign-in methods and both sessions, with the current one marked This device

The new user also shows under Authentication → Users in the console.

Until you connect an email provider, emails go out from the Nulvless shared sender, which has a low hourly limit. Connect your own before real users sign up. The Communications guide shows how.

Where to go next

  • Run the app locally with a .env.local copied from .env.example. Add http://localhost:5173 to the redirect URIs, and point the confirmation URL at http://localhost:5173/activate while you test.
  • Ask for a second factor at sign-in: turn on a method under Authentications and the example already shows the code step. React authentication with MFA explains how it works.
  • Keep test users out of production with a separate environment for preview deploys: Why staging users can never reach production.

Keep reading

Guides6 min read

Introduction to projects

A project is one product. This guide covers what it holds, how it relates to organizations and environments, and every step from creating it to serving real users.

Gleisson Matos