Help me understand VERCEL_URL, NEXTAUTH_URL, NEXTAUTH_SECRET

I am trying out v0 after using Replit. I’m an engineer, but not super experienced with Typescript/Nextjs.

I have started a nextjs app that requires creating an account and logging in. So far, the preview mode is showing a home page with the right set of features. I can work with it. The project tree looks good.

But when the preview loads, v0 Is prompting me to set my VERCEL_URL - as a first time user one hour into a project, I have no idea what that is or how to discover it.

When I asked v0 about it, this was the reply:

Issue 1: Missing Environment Variables (VERCEL_URL)

You don’t need to manually set VERCEL_URL - this is automatically set by Vercel in production environments. For local development or preview environments, you should:

  1. Set NEXTAUTH_URL directly instead:
NEXTAUTH_URL=http://localhost:3000

(or whatever your preview URL is)

My issue with this is, I don’t even know what my preview URL is, I have barely read the docs on nextauth, and just not sure how to proceed.

Is the v0 preview/dev-env considered to be “running locally” ? Asking because, v0 suggested

Additional Troubleshooting Steps

Make sure your .env.local has these values

NEXTAUTH_SECRET=your_secret_here
NEXTAUTH_URL=http://localhost:3000

But when I look at the file list, there is no .env.local

Thus, my confusion - where would put environment variables, even if I knew what to provide for the values?

Did you know about these other v0 resources? A human should be here soon to help, but the answer may already be available even faster in one of these other posts.

This guide is a great place to start.

And these recordings can give you a look at v0 features and strategies in action: Topics tagged v0

Hi @phpguru, welcome to the Vercel Community!

I understand the issue you’re facing here. v0 can sometimes extrapolate on the issue and provide solutions, which are more applicable for local development instead of the v0 environment.

Now moving on to the actual issue, VERCEL_URL is a system environment variable that is set in both runtime and build time by Vercel.

You can set environment variables for your v0 project from the Project settings:

I think if you’re using NextAuth then you need to set the NEXTAUTH_URL and a randomly generated secret with the NEXTAUTH_SECRET variables.

You can get the URL for NEXTAUTH_URL by clicking the deploy button.