import { NextRequest, NextResponse } from "next/server";import { verifySignatureAppRouter } from "@upstash/qstash/dist/nextjs";async function handler(_req: NextRequest) { await new Promise((r) => setTimeout(r, 1000)); console.log("Success"); return NextResponse.json({ name: "John Doe " });}export const POST = verifySignatureAppRouter(handler);
/app/api/qstash-edge/route.ts
Copy
Ask AI
import { NextRequest, NextResponse } from "next/server";import { verifySignatureEdge } from "@upstash/qstash/dist/nextjs";async function handler(_req: NextRequest) { await new Promise((r) => setTimeout(r, 1000)); console.log("Success"); return NextResponse.json({ name: "John Doe" });}export const POST = verifySignatureEdge(handler);export const runtime = "edge";
verifySignature or verifySignatureEdge will try to load QSTASH_CURRENT_SIGNING_KEY and
QSTASH_NEXT_SIGNING_KEY from the environment. If one of them is missing, an
error is thrown. We will set these in step 5.
4
Deploy to Vercel
I’m deploying using Vercel’s CLI, but you could
also push your project to a remote repo and deploy that way. If you have never
used the cli, please run npx vercel login before.
See here
You can accept all the default settings.
Copy
Ask AI
$ npx vercelVercel CLI 24.2.5? Set up and deploy “~/github/upstash/qstash-examples/vercel-nextjs”? [Y/n] y? Which scope do you want to deploy to? Andreas Thomas? Link to existing project? [y/N] n? What’s your project’s name? vercel-nextjs? In which directory is your code located? ./Auto-detected Project Settings (Next.js):- Build Command: next build- Output Directory: Next.js default- Development Command: next dev --port $PORT? Want to override the settings? [y/N] n🔗 Linked to chronark/vercel-nextjs (created .vercel)🔍 Inspect: https://vercel.com/chronark/vercel-nextjs/FZScmeKCWr5snn6P8voyv3W28npf [904ms]✅ Production: https://vercel-nextjs-two-sandy.vercel.app [copied to clipboard] [37s]📝 Deployed to production. Run `vercel --prod` to overwrite later (https://vercel.link/2F).💡 To change the domain or build command, go to https://vercel.com/chronark/vercel-nextjs/settings
5
Set Signing Keys in Vercel
Go to your project’s settings and set the following environment variables:
6
Redeploy to use the new environment variables
To make the added environment variables take effect, you must redeploy your
project.