src/app/page.tsx
, let’s create a simple UI to trigger the background job
using a button.Beautiful
publishJSON
method.
In this example, we’re using Next.js server actions, but you can also use route handlers.Since we don’t have our public API endpoint yet, we can use Request Catcher to test the background job.
This will eventually be replaced with our own API endpoint.startBackgroundJob
function when the button is clicked.Verification screenshots
Logs
tab where you can see your message activities.startBackgroundJob
function to use our new endpoint.There’s 1 problem: our endpoint is not public. We need to make it public so that QStash can call it.
We have 2 options:Deploying to Vercel
Error catching and security
verifySignatureAppRouter
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.Logs