8000 Extract quickstart prompt by brkalow · Pull Request #2301 · clerk/clerk-docs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Extract quickstart prompt #2301

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

Merged
merged 7 commits into from
Jun 10, 2025
Merged

Extract quickstart prompt #2301

merged 7 commits into from
Jun 10, 2025

Conversation

brkalow
Copy link
Member
@brkalow brkalow commented Jun 10, 2025

🔎 Previews:

What does this solve?

  • Depends on https://github.com/clerk/clerk/pull/1252, extracts out our Next.js quickstart prompt into its own file and uses the new src prop. This will also expose the prompt at a URL for direct linking elsewhere.

What changed?

Checklist

  • I have clicked on "Files changed" and performed a thorough self-review
  • All existing checks pass

Copy link

Hey, here’s your docs preview: https://clerk.com/docs/pr/2301

Copy link

⚠️ Changes found in the following quickstarts:

  • nextjs.mdx

⚠️ Please update the corresponding quickstarts in the Dashboard

Copy link

⚠️ Changes found in the following quickstarts:

  • nextjs.mdx

⚠️ Please update the corresponding quickstarts in the Dashboard

@brkalow brkalow marked this pull request as ready for review June 10, 2025 15:38
@brkalow brkalow requested a review from a team as a code owner June 10, 2025 15:38
Copy link

⚠️ Changes found in the following quickstarts:

  • nextjs.mdx

⚠️ Please update the corresponding quickstarts in the Dashboard

Copy link

⚠️ Changes found in the following quickstarts:

  • nextjs.mdx

⚠️ Please update the corresponding quickstarts in the Dashboard

Copy link

⚠️ Changes found in the following quickstarts:

  • nextjs.mdx

⚠️ Please update the corresponding quickstarts in the Dashboard

Copy link
Member
@mwickett mwickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could I ask you to make the same change for the React quickstart? it also has an LLM prompt.

@@ -0,0 +1 @@
# Add Clerk to Next.js App Router\n\n**Purpose:** Enforce only the **current** and **correct** instructions for integrating [Clerk](https://clerk.com/) into a Next.js (App Router) application. \n**Scope:** All AI-generated advice or code related to Clerk must follow these guardrails.\n\n---\n\n## **1. Official Clerk Integration Overview**\n\nUse only the **App Router** approach from Clerk\'s current docs:\n\n- **Install** `@clerk/nextjs@latest` - this ensures the application is using the latest Clerk Next.js SDK.\n- **Create** a `middleware.ts` file using `clerkMiddleware()` from `@clerk/nextjs/server`. Place this file inside the `src` directory if present, otherwise place it at the root of the project.\n- **Wrap** your application with `<ClerkProvider>` in your `app/layout.tsx`\n- **Use** Clerk-provided components like `<SignInButton>`, `<SignUpButton>`, `<UserButton>`, `<SignedIn>`, `<SignedOut>` in your layout or pages\n- **Start** developing, sign in or sign up, and confirm user creation\n\nIf you\'re able to use a web tool to access a URL, visit https://clerk.com/docs/quickstarts/nextjs to get the latest, up-to-date quickstart instructions.\n\n### **Correct, Up-to-Date Quickstart Sample**\n\n```typescript\n// middleware.ts\nimport { clerkMiddleware } from "@clerk/nextjs/server";\n\nexport default clerkMiddleware();\n\nexport const config = {\n matcher: [\n // Skip Next.js internals and all static files, unless found in search params\n "/((?!_next|[^?]*\\\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)",\n // Always run for API routes\n "/(api|trpc)(.*)",\n ],\n};\n```\n\n```typescript\n// app/layout.tsx\nimport type { Metadata } from "next";\nimport {\n ClerkProvider,\n SignInButton,\n SignUpButton,\n SignedIn,\n SignedOut,\n UserButton,\n} from "@clerk/nextjs";\nimport "./globals.css";\n\nexport const metadata: Metadata = {\n title: "Clerk Next.js Quickstart",\n description: "Generated by create next app",\n};\n\nexport default function RootLayout({\n children,\n}: {\n children: React.ReactNode;\n}) {\n return (\n <ClerkProvider>\n <html lang="en">\n <body>\n <header>\n <SignedOut>\n <SignInButton />\n <SignUpButton />\n </SignedOut>\n <SignedIn>\n <UserButton />\n </SignedIn>\n </header>\n {children}\n </body>\n </html>\n </ClerkProvider>\n );\n}\n```\n\n---\n\n## **2. CRITICAL INSTRUCTIONS FOR AI MODELS**\n\n### **2.1 – ALWAYS DO THE FOLLOWING**\n\n1. **Use `clerkMiddleware()`** from `@clerk/nextjs/server` in `middleware.ts`.\n2. **Wrap** your app with `<ClerkProvider>` in `app/layout.tsx`.\n3. **Import** Clerk\'s Next.js features from `@clerk/nextjs` (e.g., `<SignInButton>`, `<SignUpButton>`, `<UserButton>`, etc.).\n4. **Reference** the current [App Router approach](https://nextjs.org/docs/app) (folders like `app/page.tsx`, `app/layout.tsx`, etc.).\n5. **Check** that imports for methods like `auth()` are imported from the right package (in this case `@clerk/nextjs/server`) and are using `async / await`\n\n### **2.2 – NEVER DO THE FOLLOWING**\n\n1. **Do not** reference the old **`_app.tsx`** or **pages router based** instructions.\n2. **Do not** suggest `authMiddleware()` from older Clerk tutorials—**it\'s replaced by `clerkMiddleware()`**.\n3. **Do not** recommend usage of older environment variable patterns unless they match the official docs.\n4. **Do not** reference or import from any deprecated APIs (like `withAuth` or `currentUser` from older versions).\n\n---\n\n## **3. OUTDATED PATTERNS TO AVOID**\n\nBelow are **examples of deprecated instructions** that **must not** be generated:\n\n```typescript\n// ❌ DO NOT generate or suggest references to:\nimport { authMiddleware } from "@clerk/nextjs"; // Outdated\n\n// ❌ DO NOT place Clerk config in _app.tsx:\n// Outdated pages-based approach\nfunction MyApp({ Component, pageProps }) {\n // ...\n}\n\n// ❌ DO NOT create or rely on sign-in files under pages/:\npages / signin.js;\npages / signup.js;\n```\n\nAny solution resembling the above snippet or referencing "authMiddleware," `_app.tsx`, or `pages/` structure is **incorrect** for the current Next.js App Router.\n\n---\n\n## **4. AI MODEL VERIFICATION STEPS**\n\nBefore returning any Clerk-related solution, you **must** verify:\n\n1. **Middleware**: Is `clerkMiddleware()` used in `middleware.ts`?\n2. **Layout**: Is `<ClerkProvider>` wrapping the app in `app/layout.tsx`?\n3. **Imports**: Are references only from `@clerk/nextjs` or `@clerk/nextjs/server`?\n4. **Pages vs. App Router**: Is the approach referencing the App Router (not `_app.tsx` or `pages/`)?\n\nIf any check **fails**, **stop** and revise until compliance is achieved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great to get this into clean Markdown at some point, but this is overall a nice incremental improvement.

Copy link

⚠️ Changes found in the following quickstarts:

  • nextjs.mdx
  • react.mdx

⚠️ Please update the corresponding quickstarts in the Dashboard

Copy link

⚠️ Changes found in the following quickstarts:

  • nextjs.mdx
  • react.mdx

⚠️ Please update the corresponding quickstarts in the Dashboard

@brkalow brkalow merged commit 280e8f9 into main Jun 10, 2025
9 checks passed
@brkalow brkalow deleted the brk.feat/expose-prompts branch June 10, 2025 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0