Clerk + Next.js middleware
Protect routes with Clerk's middleware in Next.js App Router.
Snippet'ler
Auth, AI, web, data, web3, ops için hazır TS/Python boilerplate'leri. Kopyala, yapıştır, AI'a 'genişlet' de.
29 kayıt
Protect routes with Clerk's middleware in Next.js App Router.
Server-side session lookup with Lucia in a server component.
Verify an HS256/RS256 JWT and extract claims with jose.
Email + password sign-in with Auth.js (NextAuth) v5.
Constant-time HMAC verification for incoming webhooks.
Stream tokens from Claude Sonnet 4.6 via the official SDK.
Minimal loop: model picks a tool, you run it, feed the result back.
Mark a long system prompt as cacheable to cut token cost on repeated calls.
Stream a chat completion from GPT-4o with the official SDK.
Embed many texts in one call. Cheaper + faster than one-at-a-time.
Brute-force cosine search over an in-memory vector store. Works for ≤10k chunks.
Define a typed tool with Zod and let the model invoke it through generateText.
Coerce the model to return parseable JSON. Wrap with jsonrepair fallback.
Cancel slow requests, retry transient 5xx with exponential backoff.
Delay a value update until N ms after the last change. For search-as-you-type.
Trigger when an element enters the viewport. Lazy load + infinite scroll.
Form posts directly to a server function. No client state library.
Per-IP fixed window rate limit at the edge.
Server signs, browser PUTs directly to S3 — no payload through your server.
Typed Postgres schema with one-to-many relation. Drives migrations.
Multi-step write that rolls back on any error.
App-level lock keyed by an int, useful for preventing duplicate cron runs.
Wrap any async function to memoize its result in Redis with TTL.