-
Notifications
You must be signed in to change notification settings - Fork 472
docs(nextjs): Point agents at clerk init from the exports they read #9665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shane-kercheval
wants to merge
8
commits into
main
Choose a base branch
from
docs/nextjs-cli-hint-in-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+24
β2
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
553643a
docs(nextjs): Surface clerk init in exported doc comments
shane-kercheval d9a2014
docs(nextjs): Link the CLI docs instead of a bare URL
shane-kercheval 487fcca
Merge branch 'main' into docs/nextjs-cli-hint-in-types
shane-kercheval 4895b22
Merge branch 'main' into docs/nextjs-cli-hint-in-types
shane-kercheval 0d44f5c
docs(nextjs): Correct the env file, npx flag and account claim
shane-kercheval 42746de
Merge remote-tracking branch 'origin/docs/nextjs-cli-hint-in-types' iβ¦
shane-kercheval c90a62c
docs review
SarahSoutoul 28bd7aa
docs(nextjs): Restore original CLI command
SarahSoutoul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@clerk/nextjs': patch | ||
| --- | ||
|
|
||
| Add a note to the `ClerkProvider`, `clerkMiddleware()` and `auth()` doc comments explaining that `npx clerk@latest init` creates a Clerk application and writes its keys with no Clerk account or login required. Update the README prerequisites and installation section to say the same, replacing the statement that an existing Clerk application and account are required. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -34,11 +34,15 @@ | |||||
| - Next.js 15.2.8 or later | ||||||
| - React 18 or later | ||||||
| - Node.js `>=20.9.0` or later | ||||||
| - An existing Clerk application. [Create your account for free](https://dashboard.clerk.com/sign-up?utm_source=github&utm_medium=clerk_nextjs). | ||||||
| - A Clerk application. Run `npx -y clerk@latest init` to create one and write its keys to your `.env.local` file. No Clerk account required to get started β it can provision temporary development keys. Or [create your account](https://dashboard.clerk.com/sign-up?utm_source=github&utm_medium=clerk_nextjs) and copy the keys from the dashboard. | ||||||
|
|
||||||
| ### Installation | ||||||
|
|
||||||
| The fastest way to get started with Clerk is by following the [Next.js Quickstart](https://clerk.com/docs/quickstarts/nextjs?utm_source=github&utm_medium=clerk_nextjs). | ||||||
| The fastest way to get started is the Clerk CLI. In an existing Next.js project, run `npx -y clerk@latest init`. In an empty directory, run `npx -y clerk@latest init --framework next` and it scaffolds the Next.js app as well. | ||||||
|
|
||||||
| Either way it installs `@clerk/nextjs`, creates a Clerk application, writes the keys to your `.env.local` file, and adds `<ClerkProvider>`, the middleware, and sign-in and sign-up pages. No Clerk account required to get started β it can provision temporary development keys. | ||||||
|
|
||||||
| To set things up by hand instead, follow the [Next.js Quickstart](https://clerk.com/docs/quickstarts/nextjs?utm_source=github&utm_medium=clerk_nextjs). | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
That link was outdated, and redirected to the new link dropping the UTM parameters as a result. So I'd update it to this. |
||||||
|
|
||||||
| You'll learn how to install `@clerk/nextjs`, set up your environment keys, add `<ClerkProvider>` to your application, use the Clerk middleware, and use Clerk's prebuilt components. | ||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π― Functional Correctness | π‘ Minor | β‘ Quick win
π Supported by static analysis
π Script executed:
Repository: clerk/javascript
Length of output: 154
π Script executed:
Repository: clerk/javascript
Length of output: 20869
π Web query:
site:clerk.com/docs "clerk init" "--framework next" "--pm"π‘ Result:
The clerk init command is primarily intended for initializing Clerk in your project by automatically detecting the framework and package manager [1][2]. You generally do not need to manually pass the --framework or --pm flags for existing projects, as the Clerk CLI will automatically detect these settings [1][3][2]. Clerk recommends using the following command for existing projects: npx -y clerk@latest init If you are using the CLI to scaffold a fresh application or if you explicitly need to override the automatic detection, the supported usage is: clerk init --framework next --pm In this command: --framework next specifies that you are working with a Next.js project [1][2]. --pm allows you to specify your preferred package manager (e.g., npm, pnpm, yarn, or bun) [1][2]. When running this command, the CLI will: 1. Install the necessary Clerk SDK (
@clerk/nextjs) [1][2]. 2. Apply the required framework setup, such as providers, middleware, and environment configuration [1][2]. 3. Write your development API keys (NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY) to your.env.local file [3][4][5]. Do not use these flags unless you are overriding the default detection or specifically need to specify them, as it is unnecessary for most existing projects [1][3].Citations:
π Script executed (no clone):
Length of output: 50346
Specify the package manager for empty-directory scaffolding.
The empty-directory
clerk initflow requires a package-manager selection. Add--pm pnpmto the command or document the selection step.π€ Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was about to flag this when I realized CodeRabbit already had - worth specifying the package manager for this empty-directory command I think since there is no project or lockfile to detect it from @shane-kercheval