# Clerk — LLM Context for Agentic Provisioning
Clerk is a drop-in authentication and user management platform. After provisioning a Clerk application, you'll have API keys to add sign-up, sign-in, and user management to any web or mobile app.
## Credentials you received
After provisioning, your credentials are in the `CLERK_AUTH_ENVIRONMENTS` environment variable as a JSON string:
```json
{
"development": {
"publishable_key": "pk_test_...",
"secret_key": "sk_test_..."
},
"production": {
"publishable_key": "pk_live_...",
"secret_key": "sk_live_...",
"domain": "yourapp.com",
"dns_setup_required": true,
"dns_setup_url": "https://dashboard.clerk.com/..."
}
}
```
- **publishable_key** (starts with `pk_test_` or `pk_live_`) — Used client-side. Safe to expose in frontend code.
- **secret_key** (starts with `sk_test_` or `sk_live_`) — Used server-side. Keep secret — never expose in client code, git repos, or logs.
- **development** credentials are always present. Use these for local development.
- **production** credentials are present only if a `production_domain` was provided during provisioning. If `dns_setup_required` is true, visit the `dns_setup_url` to configure DNS before going live.
## Environment setup by framework
Extract the keys from `CLERK_AUTH_ENVIRONMENTS` and set them as your framework expects. Use the `development` keys for local development.
### Next.js
Add to `.env.local`:
```bash
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_... # from development.publishable_key
CLERK_SECRET_KEY=sk_test_... # from development.secret_key
```
### React (Vite)
Add to `.env`:
```bash
VITE_CLERK_PUBLISHABLE_KEY=pk_test_... # from development.publishable_key
```
### Express / Node.js
Add to `.env`:
```bash
CLERK_PUBLISHABLE_KEY=pk_test_... # from development.publishable_key
CLERK_SECRET_KEY=sk_test_... # from development.secret_key
```
### For production deployment
When deploying, use the `production` keys instead:
```bash
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_... # from production.publishable_key
CLERK_SECRET_KEY=sk_live_... # from production.secret_key
```
## Quick start by framework
### Next.js (recommended)
```bash
npm install @clerk/nextjs
```
**middleware.ts** (project root):
```typescript
import { clerkMiddleware } from '@clerk/nextjs/server'
export default clerkMiddleware()
export const config = {
matcher: [
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
'/(api|trpc)(.*)',
],
}
```
**app/layout.tsx**:
```tsx
import { ClerkProvider } from '@clerk/nextjs'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (