Accountless setup for Clerk in Next.js
- Category
- Company
- Published
One command provisions a claimable Clerk app and writes your development keys. No need to stop and create an account.

Agents stall on account creation. Asking you for permission to create an account for a service slows you and your agent down. That's why we made Clerk setup accountless: you can build without signing up, logging in, or creating an app in the Dashboard.
The blocker is API keys. Every app needs them, and until now that meant a person creating an account and copying and pasting keys by hand. Starting in @clerk/nextjs 7.8.0, an app without Clerk keys throws an error that tells you and your agent to run npx clerk@latest init. That command writes the keys without a signup or a login, so the agent keeps going. If it handles setup end to end, you may never see the error.
Let's show you how it works.
The error is the onboarding
The error itself is deliberate. We wrote it for both humans and agents: plain instruction, no jargon, and the exact commands to run.
When you or your agent hit it, the next step is in the message: npx clerk@latest init.
One command, no account
npx clerk@latest init detects your framework, installs the SDK, scaffolds the integration, and writes your keys in one command. Run it while signed out and it creates an accountless application. It's a real Clerk app with development keys, not attached to any account yet.
While signed out, every agent run on a supported framework is accountless. In a terminal, new projects are accountless, and an existing project opens the interactive login instead. Pass --accountless to force it, including while signed in, or --login to force the authenticated flow.
If you already have a Clerk app, link it instead. npx clerk@latest link opens an app picker, or takes --app <id> so an agent can run it, and npx clerk@latest env pull then writes that app's development keys. Once you claim an accountless app, its keys are also on the API keys page in the Clerk Dashboard.
How accountless works
Start to finish, a run looks like this.
-
Run the command. In an agent environment the CLI detects the non-interactive context and runs end to end without prompting. Run it yourself on a new project and it confirms the framework, the package manager, and the project name, then previews the file changes before writing them.
npx clerk@latest init -
Read what it wrote.
<ClerkProvider>goes inside<body>in your root layout, andclerkMiddleware()is imported from@clerk/nextjs/server. If your project already has amiddlewareorproxyfile, the CLI writes into that one; otherwise it names the file for your Next.js version (proxy.tson 16 and later,middleware.tson 15 and below, andproxy.tswhen the version can't be determined). Where it finds existing non-Clerk middleware, it composesclerkMiddleware()with what's there rather than rewriting the file. One exception: a non-i18n middleware file that exports its ownconfigmatcher is markedSKIPin the preview, and you addclerkMiddleware()yourself. -
Start the dev server. The application runs against the development keys in
.env.local. In server code,auth()andcurrentUser()are imported from@clerk/nextjs/server. Both are async. -
Check the setup.
npx clerk@latest doctorinspects your CLI session, the linked application, and the project, and reports each failing check with a remedy where it has one.--fixoffers to apply the remedies it can automate, which are signing in, linking the project, and runningenv pull, and reports the rest without offering to fix them. It is skipped entirely under--jsonor outside a TTY, which is why agents runnpx clerk@latest doctor --jsonand read theremedyfield instead.
Claim it and go to production
Keeping the app is two more steps.
-
Claim the application.
npx clerk@latest auth loginsigns you in and attaches the unclaimed application to your account. Unclaimed applications and development keys are not production-ready. -
Go to production. Run
npx clerk@latest deployyourself. It's an interactive wizard that creates the production instance and walks you through DNS records and OAuth providers, so an agent gets a read-only handoff from it, not a deploy. Then put the production keys where your deployment reads them.npx clerk@latest env pull --instance prodwrites the production publishable key and secret key into the env file it detects, usually.env.development.localor.env.local, replacing the development values in place with no prompt and no backup. Pass--filewith a path of your own to keep production keys out of the file your dev server reads.
Read the Clerk CLI docs for the full command reference.
Agent-first, human-ready
Our onboarding was built for a person who lands on the signup page and creates an application in the Dashboard. More of that work happens inside an agent session now. The entry point for getting started moved to the command line. Signing up still exists. It happens after your app is already running.
Point your agent at a Next.js project and tell it to add authentication.

Ready to get started?
Start building