DC-5238 Astro Clerk Example#8389
Conversation
WalkthroughAdds a new Clerk + Astro + Prisma example at orm/clerk-astro: project configs, Prisma schema and client, Clerk middleware and webhook handler, a sample page, TypeScript typings, docs/.gitignore/.env example, and a CI test-run script to boot Prisma and the dev frontend for automated tests. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Clerk as Clerk (external)
participant API as Astro API (/api/webhooks/clerk)
participant Prisma as Prisma Client / DB
Note right of API `#DDEBF7`: Webhook verification + upsert flow
Clerk->>API: POST webhook (user.created) + signature
activate API
API->>API: Verify signature (CLERK_WEBHOOK_SIGNING_SECRET)
alt invalid signature
API-->>Clerk: 400 Bad Request
else valid signature
API->>Prisma: Upsert user (clerkId unique, email, name)
Prisma-->>API: Upsert result
API-->>Clerk: 200 OK
end
deactivate API
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Possibly related PRs
Pre-merge checks✅ Passed checks (3 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
orm/clerk-astro/astro.config.mjs (1)
1-12: Astro config looks correct; confirm the hard-coded ngrok hostThe integration/adapter/output pieces are aligned with a server‑rendered Astro app using Clerk. The only thing to double‑check is
allowedHosts: ["localhost", "00c910def28e.ngrok-free.app"]: that ngrok subdomain looks like a personal, transient URL, so confirm whether you want to commit that specific host or replace it with something more generic/placeholder for other users running their own ngrok tunnel.orm/clerk-astro/prisma/schema.prisma (1)
1-15: Align generator config with driver adapter best practicesThe generator and model look good and are consistent with
src/lib/prisma.ts. Since you’re using@prisma/adapter-pgwithprovider = "prisma-client", consider adding:generator client { provider = "prisma-client" output = "../src/generated/prisma" engineType = "client" }This configuration avoids bundling Rust query engine binaries when using driver adapters and better matches Prisma’s recommended setup for adapter‑based clients. Based on learnings.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
orm/clerk-astro/public/favicon.svgis excluded by!**/*.svg
📒 Files selected for processing (13)
.github/tests/orm/clerk-astro/run.sh(1 hunks)orm/clerk-astro/.gitignore(1 hunks)orm/clerk-astro/README.md(1 hunks)orm/clerk-astro/astro.config.mjs(1 hunks)orm/clerk-astro/package.json(1 hunks)orm/clerk-astro/prisma.config.ts(1 hunks)orm/clerk-astro/prisma/schema.prisma(1 hunks)orm/clerk-astro/src/env.d.ts(1 hunks)orm/clerk-astro/src/lib/prisma.ts(1 hunks)orm/clerk-astro/src/middleware.ts(1 hunks)orm/clerk-astro/src/pages/api/webhooks/clerk.ts(1 hunks)orm/clerk-astro/src/pages/index.astro(1 hunks)orm/clerk-astro/tsconfig.json(1 hunks)
🧰 Additional context used
🧠 Learnings (8)
📚 Learning: 2025-10-27T13:18:46.546Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/fastify-graphql-sdl-first/src/context.ts:1-1
Timestamp: 2025-10-27T13:18:46.546Z
Learning: In the prisma/prisma-examples repository, generated Prisma client files (typically at paths like `prisma/generated/client`) are intentionally not committed to the repository. These files are generated at build/test time. Do not flag missing generated client artifacts as issues in reviews.
Applied to files:
orm/clerk-astro/.gitignoreorm/clerk-astro/prisma/schema.prismaorm/clerk-astro/src/lib/prisma.ts
📚 Learning: 2025-10-15T13:58:59.096Z
Learnt from: AmanVarshney01
Repo: prisma/prisma-examples PR: 8327
File: orm/graphql-auth/prisma/schema.prisma:2-4
Timestamp: 2025-10-15T13:58:59.096Z
Learning: The "prisma-client" generator provider (introduced in Prisma v6) is the newer, ESM-ready alternative to "prisma-client-js". It requires an explicit output path and is better suited for modern runtimes, edge deployments, and will become the default in Prisma v7. Use "prisma-client" for new projects or when modernizing existing projects.
Applied to files:
orm/clerk-astro/.gitignoreorm/clerk-astro/prisma/schema.prismaorm/clerk-astro/prisma.config.tsorm/clerk-astro/src/lib/prisma.ts
📚 Learning: 2025-08-22T12:12:24.602Z
Learnt from: FGoessler
Repo: prisma/prisma-examples PR: 8260
File: generator-prisma-client/nextjs-starter-webpack-turborepo/packages/database/package.json:13-13
Timestamp: 2025-08-22T12:12:24.602Z
Learning: When analyzing changes from package.json seed scripts to "prisma db seed", always verify the actual content of prisma.config.ts rather than relying solely on regex patterns, as the configuration may be properly defined but in a format that doesn't match overly restrictive search patterns.
Applied to files:
orm/clerk-astro/.gitignore.github/tests/orm/clerk-astro/run.shorm/clerk-astro/prisma.config.tsorm/clerk-astro/package.json
📚 Learning: 2025-10-15T13:58:29.130Z
Learnt from: AmanVarshney01
Repo: prisma/prisma-examples PR: 8327
File: orm/fastify-graphql/prisma/schema.prisma:2-4
Timestamp: 2025-10-15T13:58:29.130Z
Learning: In Prisma v6.15 and later, `provider = "prisma-client"` is a valid generator configuration value when combined with `engineType = "client"`. This configuration generates a Prisma client without Rust engine binaries, relying on JavaScript driver adapters instead, and is different from the traditional `provider = "prisma-client-js"` configuration.
Applied to files:
orm/clerk-astro/prisma/schema.prismaorm/clerk-astro/src/lib/prisma.ts
📚 Learning: 2025-10-15T13:56:01.807Z
Learnt from: AmanVarshney01
Repo: prisma/prisma-examples PR: 8327
File: orm/graphql-subscriptions/prisma/schema.prisma:1-5
Timestamp: 2025-10-15T13:56:01.807Z
Learning: In Prisma v6.15 and later, `engineType = "client"` is a valid generator configuration value that generates a Prisma client without Rust engine binaries, relying on JavaScript driver adapters instead (e.g., prisma/adapter-pg). This is useful for edge and serverless deployments.
Applied to files:
orm/clerk-astro/prisma/schema.prismaorm/clerk-astro/src/lib/prisma.ts
📚 Learning: 2025-10-27T13:18:46.546Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/fastify-graphql-sdl-first/src/context.ts:1-1
Timestamp: 2025-10-27T13:18:46.546Z
Learning: The prisma/prisma-examples repository is a monorepo containing many independent example projects. When reviewing PRs in this repository, focus only on the files actually changed by the author in that specific PR, not on other example projects or infrastructure that wasn't modified.
Applied to files:
orm/clerk-astro/README.md
📚 Learning: 2025-10-24T17:50:48.569Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/betterauth-astro/src/pages/sign-up/index.astro:20-36
Timestamp: 2025-10-24T17:50:48.569Z
Learning: Do not suggest code changes or improvements to code in Prisma example repositories (prisma/prisma-examples). These examples are carefully set up and intentionally aligned with external documentation and information.
Applied to files:
orm/clerk-astro/README.md
📚 Learning: 2025-08-22T12:12:43.161Z
Learnt from: FGoessler
Repo: prisma/prisma-examples PR: 8260
File: generator-prisma-client/nextjs-starter-turbopack/components/quotes.tsx:1-1
Timestamp: 2025-08-22T12:12:43.161Z
Learning: In Next.js applications using Prisma, the connection() function from 'next/server' serves a different purpose than 'export const dynamic = force-dynamic'. The connection() function ensures proper database connection context and request isolation, while dynamic = 'force-dynamic' only controls rendering strategy. Both should be used together and are not redundant.
Applied to files:
orm/clerk-astro/src/lib/prisma.ts
🧬 Code graph analysis (2)
.github/tests/orm/clerk-astro/run.sh (1)
generator-prisma-client/aws-lambda-sst-esbuild/sst.config.ts (1)
run(16-33)
orm/clerk-astro/src/lib/prisma.ts (1)
orm/prisma-mocking-javascript/client.js (1)
adapter(4-4)
🪛 markdownlint-cli2 (0.18.1)
orm/clerk-astro/README.md
11-11: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
17-17: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
25-25: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
31-31: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
62-62: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
73-73: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
81-81: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
85-85: Bare URL used
(MD034, no-bare-urls)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test (orm/grpc)
🔇 Additional comments (9)
orm/clerk-astro/.gitignore (1)
1-26: Ignore patterns align with build artifacts and generated Prisma client outputThe file cleanly ignores Astro build output, dependencies, local env/IDE files, and the generated Prisma client directory under
/src/generated/prisma, which matches how this repo treats generated clients.orm/clerk-astro/README.md (1)
1-97: Setup instructions match the new Clerk + Astro + Prisma exampleThe README’s flow (template usage, env setup, Prisma Postgres, Clerk app + webhooks, ngrok, and
npm run devon port 4321) is coherent with the project structure and should be sufficient to get the example running.orm/clerk-astro/package.json (1)
1-25: Manifest and scripts are consistent with the example’s toolingThe script section and dependency/devDependency split line up with an Astro app using Prisma, pg, and Clerk, and there’s nothing obviously off in this configuration.
orm/clerk-astro/src/env.d.ts (1)
1-10: Env typings cover the expected database and Clerk variables
ImportMetaEnvdeclares DATABASE_URL and the Clerk webhook/signing/key variables, and wiring it intoImportMetashould provide the intended type safety aroundimport.meta.env. Just keep this file in sync if you later add or rename env vars.orm/clerk-astro/tsconfig.json (1)
1-5: TypeScript configuration is minimal and appropriate for this projectExtending the strict Astro preset, including the generated Astro types plus all source files, and excluding
distis a clean setup for this example.orm/clerk-astro/src/pages/index.astro (1)
1-28: Index page cleanly wires auth-aware header stateThe page frontmatter and markup provide a simple, clear split between signed‑out (sign‑in button) and signed‑in (user button) states, with a minimal HTML shell around it; no issues stand out here.
orm/clerk-astro/src/middleware.ts (1)
1-3: LGTM – Clerk middleware wiring is minimal and appropriateThe
onRequest = clerkMiddleware()export cleanly hooks Clerk into Astro’s middleware pipeline with no obvious pitfalls for this example.orm/clerk-astro/src/lib/prisma.ts (1)
1-12: Prisma client + PostgreSQL adapter wiring looks correctImport path,
PrismaPgadapter configuration withDATABASE_URL, and the single exportedPrismaClientinstance are all consistent with the Prisma driver‑adapter pattern and the schema’s generator/output settings.orm/clerk-astro/prisma.config.ts (1)
1-14: Prisma CLI configuration is consistent and modernUsing
defineConfigwithschema,migrations.path, anddatasource.url = env("DATABASE_URL")aligns well with the rest of the setup (schema +src/lib/prisma.ts) and centralizes DB configuration neatly.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
orm/clerk-astro/.env.example(1 hunks)orm/clerk-astro/README.md(1 hunks)orm/clerk-astro/astro.config.mjs(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-27T13:18:46.546Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/fastify-graphql-sdl-first/src/context.ts:1-1
Timestamp: 2025-10-27T13:18:46.546Z
Learning: The prisma/prisma-examples repository is a monorepo containing many independent example projects. When reviewing PRs in this repository, focus only on the files actually changed by the author in that specific PR, not on other example projects or infrastructure that wasn't modified.
Applied to files:
orm/clerk-astro/README.md
📚 Learning: 2025-10-24T17:50:48.569Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/betterauth-astro/src/pages/sign-up/index.astro:20-36
Timestamp: 2025-10-24T17:50:48.569Z
Learning: Do not suggest code changes or improvements to code in Prisma example repositories (prisma/prisma-examples). These examples are carefully set up and intentionally aligned with external documentation and information.
Applied to files:
orm/clerk-astro/README.md
🪛 dotenv-linter (4.0.0)
orm/clerk-astro/.env.example
[warning] 6-6: [UnorderedKey] The CLERK_SECRET_KEY key should go before the PUBLIC_CLERK_PUBLISHABLE_KEY key
(UnorderedKey)
[warning] 7-7: [UnorderedKey] The CLERK_WEBHOOK_SIGNING_SECRET key should go before the PUBLIC_CLERK_PUBLISHABLE_KEY key
(UnorderedKey)
🪛 markdownlint-cli2 (0.18.1)
orm/clerk-astro/README.md
11-11: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
17-17: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
25-25: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
31-31: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
62-62: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
73-73: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
81-81: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
94-94: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
98-98: Bare URL used
(MD034, no-bare-urls)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: test (orm/astro)
- GitHub Check: test (orm/ai-sdk-nextjs)
- GitHub Check: test (orm/clerk-astro)
- GitHub Check: test (orm/betterauth-astro)
- GitHub Check: test (orm/authjs-nextjs)
- GitHub Check: test (orm/betterauth-nextjs)
- GitHub Check: test (orm/cloudflare-workers)
- GitHub Check: test (orm/clerk-nextjs)
- GitHub Check: test (orm/grpc)
- GitHub Check: test (orm/nest-graphql-sdl-first)
- GitHub Check: test (orm/nest-graphql)
- GitHub Check: test (orm/nest)
- GitHub Check: test (orm/nextjs)
- GitHub Check: test (orm/hapi-graphql)
- GitHub Check: test (orm/nextjs-graphql)
- GitHub Check: test (orm/nextjs-trpc)
- GitHub Check: test (orm/nuxt)
- GitHub Check: test (orm/react-router-7)
- GitHub Check: test (orm/sveltekit)
- GitHub Check: test (orm/solid-start)
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
orm/clerk-astro/README.md (2)
11-11: Optional: Add language identifiers to code blocks.Static analysis flagged that several fenced code blocks are missing language identifiers, which can impact rendering in some markdown processors. For example:
- Lines 11, 17, 25, 31: Could be tagged with
`bash`- Line 62:
`bash`- Lines 73, 81, 94:
`bash`Adding these identifiers (e.g.,
```bashinstead of```) would improve clarity and formatting.Also applies to: 17-17, 25-25, 31-31, 62-62, 73-73, 81-81, 94-94
98-98: Optional: URL formatting.Static analysis flagged a bare URL at line 98. If desired, you could format it as a link (e.g.,
[http://localhost:4321](http://localhost:4321)) for better markdown rendering, though this is a minor stylistic preference.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
orm/clerk-astro/README.md(1 hunks)orm/clerk-astro/astro.config.mjs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- orm/clerk-astro/astro.config.mjs
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-27T13:18:46.546Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/fastify-graphql-sdl-first/src/context.ts:1-1
Timestamp: 2025-10-27T13:18:46.546Z
Learning: The prisma/prisma-examples repository is a monorepo containing many independent example projects. When reviewing PRs in this repository, focus only on the files actually changed by the author in that specific PR, not on other example projects or infrastructure that wasn't modified.
Applied to files:
orm/clerk-astro/README.md
📚 Learning: 2025-10-24T17:50:48.569Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/betterauth-astro/src/pages/sign-up/index.astro:20-36
Timestamp: 2025-10-24T17:50:48.569Z
Learning: Do not suggest code changes or improvements to code in Prisma example repositories (prisma/prisma-examples). These examples are carefully set up and intentionally aligned with external documentation and information.
Applied to files:
orm/clerk-astro/README.md
🪛 markdownlint-cli2 (0.18.1)
orm/clerk-astro/README.md
11-11: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
17-17: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
25-25: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
31-31: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
62-62: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
73-73: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
81-81: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
94-94: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
98-98: Bare URL used
(MD034, no-bare-urls)
🔇 Additional comments (1)
orm/clerk-astro/README.md (1)
56-56: ✅ Environment variable naming corrected.The critical issue from the previous review has been addressed. Line 56 now correctly references
PUBLIC_CLERK_PUBLISHABLE_KEY(the Astro convention) instead of the Next.js variant, ensuring users will follow the correct configuration as defined in.env.example.
Summary by CodeRabbit
New Features
Documentation
Configuration
Tests
✏️ Tip: You can customize this high-level summary in your review settings.