Next.js + Drizzle + Clerk Vertical Slice

End-to-end outline for the saas-multi-tenant playbook: auth, tenant-scoped Drizzle queries, and server actions. Prefer the playbook and stack instructions for detail.

CopilotCursorKilo
AuthorNeexoCore
Updated
nextjsdrizzleclerk

Overview

Thin outline for the saas-multi-tenant playbook. Canonical detail lives in:

Vertical slice

  1. Auth — protect routes with Clerk (proxy.ts on Node; Edge middleware.ts when required — see clerk-auth)
  2. Auth context — resolve userId and orgId once; reuse everywhere
  3. Schema — tables include orgId; indexes for tenant filters
  4. Scoped query — never query tenant data without org scope
  5. Server action — validate with Zod v4 (prefer import { z } from "zod/v4"); re-check org membership before writes
  6. Validate — run the project gate (pnpm ci:check or documented fallback)

SaaS apps that also ship React Three Fiber / next-intl marketing surfaces may additionally load marketing-3d-site resources.

Raw content

Copy into your project — e.g. .instructions.md, .agent.md, or SKILL.md

## Overview

Thin outline for the [`saas-multi-tenant`](/playbooks/saas-multi-tenant) playbook. Canonical detail lives in:

- [Clerk Authentication](/instructions/clerk-auth)
- [Drizzle Database](/instructions/drizzle-database)
- [Zod v4 Validation](/instructions/zod-v4)
- [Next.js Conventions](/instructions/nextjs-conventions)

## Vertical slice

1. **Auth** — protect routes with Clerk (`proxy.ts` on Node; Edge `middleware.ts` when required — see clerk-auth)
2. **Auth context** — resolve `userId` and `orgId` once; reuse everywhere
3. **Schema** — tables include `orgId`; indexes for tenant filters
4. **Scoped query** — never query tenant data without org scope
5. **Server action** — validate with Zod v4 (prefer `import { z } from "zod/v4"`); re-check org membership before writes
6. **Validate** — run the project gate (`pnpm ci:check` or documented fallback)

SaaS apps that also ship React Three Fiber / next-intl marketing surfaces may additionally load [`marketing-3d-site`](/playbooks/marketing-3d-site) resources.

Next steps

Matched by shared tags and category. Browse all instructions