Next.js Lemon Squeezy webhook handler
Next.js App Router can receive Lemon Squeezy webhooks if the route verifies the raw request body before dispatching events.
Open the free generatorCreate a route handler
Use app/api/webhooks/lemonsqueezy/route.ts and read await request.text() so the signing payload remains exact.
Verify before dispatch
Return 401 for invalid signatures, then parse JSON and switch on meta.event_name.
Keep handlers idempotent
Persist Lemon Squeezy event IDs or order IDs so retries do not duplicate entitlement changes.
FAQ
Can I use request.json() first?
No. Parse JSON only after computing the signature from request.text().
Do retries matter?
Yes. Webhook delivery can retry; your billing side effects should be idempotent.
Use the free sample before wiring production checkout
Download a public sample pack with fake Lemon Squeezy fixtures, signature tests, contract checks, duplicate replay tests, and CI skeletons. The Pro Kit preview shows the full paid package structure without exposing the private archive.