Skip to content

upstash/workflow-js / skills

upstash-workflow-js

Unverified

Lightweight guidance for using the Upstash Workflow SDK to define, trigger, and manage workflows. Use this Skill whenever a user wants to create workflow endpoints, run steps, or interact with the Upstash Workflow client.

FileKindSize
SKILL.mdskill md2.2 KB
agents.mdmarkdown6.7 KB
basics/client.mdmarkdown4.1 KB
basics/context.mdmarkdown5.1 KB
basics/serve.mdmarkdown2.4 KB
features/flow-control.mdmarkdown3.9 KB
features/invoke.mdmarkdown2.6 KB
features/retries-failures-reliability.mdmarkdown6.3 KB
features/wait-for-event.mdmarkdown2.8 KB
features/webhooks.mdmarkdown2.5 KB
how-to/local-dev.mdmarkdown3.2 KB
how-to/middleware.mdmarkdown4.7 KB
how-to/migrations.mdmarkdown4.8 KB
how-to/realtime.mdmarkdown4.8 KB
rest-api.mdmarkdown6.6 KB
troubleshooting.mdmarkdown4.8 KB

how-to/local-dev.md

View on GitHub
# Local Development for Upstash Workflow

This documentation explains how to run Upstash Workflow locally using the QStash development server and how to expose your local app using a public tunnel such as ngrok. It focuses on practical usage and TypeScript integration.

## Overview

Upstash Workflow uses Upstash QStash under the hood. During development you can:

- Run a **local QStash development server** to simulate workflow behavior entirely offline.
- Optionally expose your local server using **ngrok** if you want to test with the production QStash.

Both approaches require updating environment variables and ensuring your workflow trigger URLs correctly reference your local or tunnel address.

---

## 1. Start the QStash Local Development Server

Use the QStash CLI:

```
npx @upstash/qstash-cli dev
```

The CLI prints:

- QSTASH_TOKEN
- QSTASH_CURRENT_SIGNING_KEY
- QSTASH_NEXT_SIGNING_KEY
- Local server URL (default: `http://127.0.0.1:8080`)

Set these values in your `.env` file so your workflow client uses the local environment.

---

## 2. Set Local Environment Variables

Use the environment values printed by the CLI:

```
QSTASH_URL="http://127.0.0.1:8080"
QSTASH_TOKEN="<token-from-cli>"
QSTASH_CURRENT_SIGNING_KEY="<cur-key>"
QSTASH_NEXT_SIGNING_KEY="<next-key>"
```

These ensure all workflow requests are routed locally.

---

## 3. Trigger Workflows Using Local URLs

A common pattern is determining the base URL dynamically based on environment variables. Below is an example that demonstrates:

- Local development (localhost)
- Production deployments (auto-detected env)

```ts
import { Client } from "@upstash/workflow";

const client = Client();

// In production, Vercel sets VERCEL_URL. Otherwise use localhost.
const BASE_URL = process.env.VERCEL_URL
  ? `https://${process.env.VERCEL_URL}`
  : `http://localhost:3000`;

// Trigger a workflow with retries
const { workflowRunId } = await client.trigger({
  url: `${BASE_URL}/api/workflow`, // Local or production
  retries: 3, // Optional retry logic
});

console.log("Workflow run:", workflowRunId);
```

**Common mistakes:**

- Forgetting to include the full URL including `http://` or `https://`.
- Using a production URL while the local QStash server is running.
- Missing environment variables.

---

## 4. Using ngrok (Optional)

If your workflow must be reachable from the managed Upstash servers (not local), expose your local server publicly.

### Install & authenticate

```
ngrok config add-authtoken <YOUR-AUTH-TOKEN>
```

### Start a tunnel

```
ngrok http 3000
```

ngrok outputs a public URL:

```
Forwarding  https://1234abcd.ngrok.io -> http://localhost:3000
```

Use this public URL instead of localhost:

```ts
const BASE_URL = "https://1234abcd.ngrok.io"; // Public tunnel

await client.trigger({
  url: `${BASE_URL}/api/workflow`,
  retries: 3,
});
```

**Pitfall:** Your ngrok port must match your dev server port, otherwise all workflow calls will fail.

---

## Summary

- Start QStash locally using `qstash-cli dev`.
- Copy generated environment variables into `.env`.
- Use local URLs in TypeScript clients while developing.
- Optionally expose your server with ngrok if you need remote access.

This setup ensures fast workflow iteration without deploying your app.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall