Skip to main content
This guide adds Nelkap to a Nuxt 4 app. By the end, your app will run a workflow that creates a new user’s profile, waits a day, and sends them a welcome email, and you’ll follow each step in your project. You need a Nelkap project with its endpoint, an API key, and its secret. If you don’t have them yet, follow the first three steps of the quickstart.
1

Install the SDK

2

Add your keys

Add your project’s API key and secret to .env:
.env
In development, Nuxt loads this file into process.env, where the SDK reads both values. The API key lets your app start runs and save steps. The secret lets your app check that each call really comes from Nelkap.Nuxt doesn’t read .env in production, so set the same two variables in your host’s settings when you deploy.
3

Create your client and your first workflow

Create server/utils/nelkap.ts. Code in the server folder only runs on the server, which keeps your keys out of the browser:
server/utils/nelkap.ts
  • onboardUser is your workflow: an async function that takes the run’s payload, here a user ID.
  • Each step.run saves what its function returns. When the run picks up after the sleep, the profile step gives back its saved result instead of creating the profile again.
  • step.sleep pauses the run for a day. Nothing runs in your app during that day.
  • registerWorkflows tells Nelkap which workflows your app runs, as soon as the file is loaded.
Replace createProfile and sendWelcomeEmail with your own functions.
4

Add the route Nelkap calls

Create a server route at the path of your endpoint. The .post in its name makes it answer POST requests only:
server/api/nelkap.post.ts
toWebRequest turns Nuxt’s request into the standard Request that handle takes. handle checks the secret, answers Nelkap at once, and runs the workflow in the background. event.waitUntil keeps that background work going once the answer is sent, on serverless hosts as on your own server.If your app checks sign-in on every route, for example in a server middleware, leave /api/nelkap out: handle checks Nelkap’s secret instead.
5

Deploy and set your endpoint

Deploy your app, so Nelkap can reach the route over the internet. Then edit your project and set its endpoint to the route’s URL, like https://your-app.com/api/nelkap.
6

Start a run

Start the workflow from any server code. Here, the sign-up route starts it once the user is created:
server/api/sign-up.post.ts
run returns as soon as Nelkap has the run, so the sign-up doesn’t wait for the workflow. Its second argument, user.id, is the run’s payload: Nelkap passes it to onboardUser.
7

Follow your run

Open your project’s runs. The new run shows the profile step with what it returned, then sleeps. A day later, Nelkap calls your route again, the welcome email goes out, and the run completes.

Long runs on serverless hosts

On a serverless host, event.waitUntil keeps a call going for as long as your function may run. If a call reaches that limit, every step already saved is kept, and Nelkap calls your app again about five minutes later to go on from there. Keep each step shorter than your host’s limit.