Skip to content

Commit 226a58c

Browse files
DX-2595: document qstash auto dev server (#688)
* feat: document automatic qstash dev server in JS SDK Documents the new devMode option in @upstash/qstash that downloads, starts, and manages the QStash dev server automatically. Adds a prominent section in the Local Development how-to and a quick mention in the TS SDK getting started page. * refactor: reorganize local-development page - Split intro paragraph - Group manual install methods under 'Running the dev server manually' - Rename 'NPX' -> '@upstash/qstash-cli', 'Artifact Repository' -> 'Direct download', 'QStash CLI' -> 'CLI reference' - Promote test users to its own h2 Also tightens the Automatic dev server section: leads with QSTASH_DEV env, drops redundant copy, and moves the production no-op into a warning callout. * docs: document automatic qstash dev server in workflow guide * docs: remove obsolete note about missing GUI client for dev server * chore(llms): regenerate llms.txt and llms-full.txt --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 77459a1 commit 226a58c

4 files changed

Lines changed: 248 additions & 17 deletions

File tree

llms-full.txt

Lines changed: 124 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8605,16 +8605,85 @@ Source: https://upstash.com/docs/qstash/howto/local-development
86058605

86068606
QStash requires a publicly available API to send messages to.
86078607
During development when applications are not yet deployed, developers typically need to expose their local API by creating a public tunnel.
8608-
While local tunneling works seamlessly, it requires code changes between development and production environments and increase friction for developers.
8608+
8609+
While local tunneling works seamlessly, it requires code changes between development and production environments and increases friction for developers.
86098610
To simplify the development process, Upstash provides QStash CLI, which allows you to run a development server locally for testing and development.
86108611

86118612
<Check>The development server fully supports all QStash features including Schedules, URL Groups, Workflows, and Event Logs.</Check>
86128613

86138614
<Note>Since the development server operates entirely in-memory, all data is reset when the server restarts.</Note>
86148615

8615-
You can download and run the QStash CLI executable binary in several ways:
8616+
## Automatic dev server (JavaScript SDK)
8617+
8618+
If you are using `@upstash/qstash`, you can just set `QSTASH_DEV=true` in your environment variables, and the SDK will download and connect to the dev server automatically.
8619+
8620+
```bash .env
8621+
QSTASH_DEV=true
8622+
```
8623+
8624+
Additionally, you can pass `devMode: true` to explicitly enable dev mode:
8625+
8626+
```typescript
8627+
import { Client } from "@upstash/qstash";
8628+
8629+
const client = new Client({ devMode: true });
8630+
8631+
await client.publishJSON({
8632+
url: "https://example.com/webhook",
8633+
body: { hello: "world" },
8634+
});
8635+
```
8636+
8637+
```typescript
8638+
// app/api/webhook/route.ts
8639+
import { verifySignatureAppRouter } from "@upstash/qstash/nextjs";
8640+
8641+
export const POST = verifySignatureAppRouter(
8642+
async (request) => {
8643+
// signed by the local dev server
8644+
return new Response("ok");
8645+
},
8646+
{ devMode: true }
8647+
);
8648+
```
8649+
8650+
On startup the SDK prints the dev server URL and a link to the Upstash Console:
8651+
8652+
```
8653+
[QStash Dev] Server running at http://127.0.0.1:8080
8654+
Console: https://console.upstash.com/qstash/local-mode-user?port=8080
8655+
```
8656+
8657+
When dev mode is active, the SDK will:
8658+
8659+
* Download the latest `qstash` binary on first use, cached in your OS cache directory:
8660+
* macOS: `~/Library/Caches/upstash/qstash-dev`
8661+
* Linux: `~/.cache/upstash/qstash-dev`
8662+
* Windows: `%LOCALAPPDATA%\upstash\qstash-dev`
8663+
* Spawn the server on port `8080` (override with `QSTASH_DEV_PORT`).
8664+
* Confirm the server is running on the configured port and skip spawning if it is.
8665+
* Override the `baseUrl`, `token`, and signing keys you provide and use the dev server's instead.
8666+
8667+
<Warning>
8668+
Dev mode is automatically a no-op when `NODE_ENV=production` and in browser/edge runtimes.
8669+
</Warning>
8670+
8671+
### Next.js edge routes
8672+
8673+
If you are using edge routes in Next.js, the SDK cannot spawn the dev server from the edge runtime — it can only verify it is reachable. To start the server before any edge request hits, call `registerQStashDev()` from `instrumentation.ts`:
8674+
8675+
```typescript
8676+
// instrumentation.ts
8677+
import { registerQStashDev } from "@upstash/qstash/nextjs";
8678+
8679+
export const register = () => registerQStashDev();
8680+
```
86168681

8617-
## NPX (Node Package Executable)
8682+
## Running the dev server manually
8683+
8684+
If you would rather run the dev server manually (Python, Go, plain HTTP, etc.), use the QStash CLI directly.
8685+
8686+
### @upstash/qstash-cli
86188687

86198688
Install the binary via the `@upstash/qstash-cli` NPM package:
86208689

@@ -8632,7 +8701,7 @@ Once you start the local server, you can go to the QStash tab on Upstash Console
86328701

86338702
<img />
86348703

8635-
## Docker
8704+
### Docker
86368705

86378706
QStash CLI is available as a Docker image through our public AWS ECR repository:
86388707

@@ -8644,7 +8713,7 @@ docker pull public.ecr.aws/upstash/qstash:latest
86448713
docker run -p 8080:8080 public.ecr.aws/upstash/qstash:latest qstash dev
86458714
```
86468715

8647-
## Artifact Repository
8716+
### Direct download
86488717

86498718
You can download the binary directly from our artifact repository without using a package manager:
86508719

@@ -8657,7 +8726,7 @@ After extracting the archive file, run the executable:
86578726
$ ./qstash dev
86588727
```
86598728

8660-
## QStash CLI
8729+
## CLI reference
86618730

86628731
Currently, the only available command for QStash CLI is `dev`, which starts a development server instance.
86638732

@@ -8684,6 +8753,8 @@ Running `qstash dev` starts two components:
86848753
$ ./qstash dev -port=8080 -log-port=9000
86858754
```
86868755

8756+
## Test users
8757+
86878758
There are predefined test users available. You can configure the quota type of users using the `-quota` option, with available options being `payg` and `pro`.
86888759
These quotas don't affect performance but allow you to simulate different server limits based on the subscription tier.
86898760

@@ -8722,8 +8793,6 @@ QSTASH_NEXT_SIGNING_KEY="sig_7GFR4YaDshFcqsxWRZpRB161jguD"
87228793

87238794
</CodeGroup>
87248795

8725-
<Info>Currently, there is no GUI client available for the development server. You can use QStash SDKs to fetch resources like event logs.</Info>
8726-
87278796
## License
87288797

87298798
The QStash development server is licensed under the [Development Server License](/docs/qstash/misc/license), which restricts its use to development and testing purposes only.
@@ -11569,6 +11638,18 @@ const client = new Client({
1156911638
});
1157011639
```
1157111640

11641+
## Local development
11642+
11643+
Pass `devMode: true` (or set `QSTASH_DEV=true`) to have the SDK download, start, and manage a local QStash dev server for you. No tokens or signing keys required — the SDK injects deterministic dev credentials.
11644+
11645+
```typescript
11646+
import { Client } from "@upstash/qstash";
11647+
11648+
const client = new Client({ devMode: true });
11649+
```
11650+
11651+
The same flag works on the receiving side — pass `devMode: true` to `Receiver` or `verifySignature*` to verify signatures with the dev server's keys. See [Local Development](/docs/qstash/howto/local-development) for the full walkthrough, including the `registerQStashDev()` helper for Next.js edge routes.
11652+
1157211653
## Telemetry
1157311654

1157411655
This sdk sends anonymous telemetry headers to help us improve your experience.
@@ -50813,6 +50894,41 @@ Source: https://upstash.com/docs/workflow/howto/local-development/development-se
5081350894
Upstash Workflow is built on top of Upstash QStash.
5081450895
The QStash CLI provides a local development server that performs QStash functionality locally for development and testing purposes.
5081550896

50897+
## Automatic dev server (recommended)
50898+
50899+
If you are using `@upstash/workflow`, you can just set `QSTASH_DEV=true` in your environment, and the SDK will download and connect to the dev server automatically. No tokens or signing keys required.
50900+
50901+
```bash .env
50902+
QSTASH_DEV=true
50903+
```
50904+
50905+
With `QSTASH_DEV=true` set, both the workflow client and the `serve()` endpoint pick up the dev server automatically. The endpoint also verifies incoming signatures against the dev server's deterministic signing keys, so signature verification works end-to-end with no extra setup.
50906+
50907+
```typescript
50908+
// app/api/workflow/route.ts
50909+
import { serve } from "@upstash/workflow/nextjs";
50910+
50911+
export const { POST } = serve(async (context) => {
50912+
await context.run("step-1", () => console.log("running locally"));
50913+
});
50914+
```
50915+
50916+
```typescript
50917+
import { Client } from "@upstash/workflow";
50918+
50919+
const client = new Client({ token: process.env.QSTASH_TOKEN ?? "" });
50920+
50921+
await client.trigger({
50922+
url: "http://localhost:3000/api/workflow",
50923+
});
50924+
```
50925+
50926+
For details on the dev server behavior, ports, and the `registerQStashDev()` helper for Next.js edge routes, see the [QStash Local Development docs](/docs/qstash/howto/local-development).
50927+
50928+
## Manual setup
50929+
50930+
If you would rather start and manage the QStash dev server yourself, follow the steps below.
50931+
5081650932
<Steps>
5081750933
<Step title="Install and Start Development Server">
5081850934
Start the development server using the QStash CLI:

qstash/howto/local-development.mdx

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,87 @@
22
title: "Local Development"
33
---
44

5-
QStash requires a publicly available API to send messages to.
5+
QStash requires a publicly available API to send messages to.
66
During development when applications are not yet deployed, developers typically need to expose their local API by creating a public tunnel.
7-
While local tunneling works seamlessly, it requires code changes between development and production environments and increase friction for developers.
7+
8+
While local tunneling works seamlessly, it requires code changes between development and production environments and increases friction for developers.
89
To simplify the development process, Upstash provides QStash CLI, which allows you to run a development server locally for testing and development.
910

1011
<Check>The development server fully supports all QStash features including Schedules, URL Groups, Workflows, and Event Logs.</Check>
1112

1213
<Note>Since the development server operates entirely in-memory, all data is reset when the server restarts.</Note>
1314

14-
You can download and run the QStash CLI executable binary in several ways:
15+
## Automatic dev server (JavaScript SDK)
16+
17+
If you are using `@upstash/qstash`, you can just set `QSTASH_DEV=true` in your environment variables, and the SDK will download and connect to the dev server automatically.
18+
19+
```bash .env
20+
QSTASH_DEV=true
21+
```
22+
23+
Additionally, you can pass `devMode: true` to explicitly enable dev mode:
24+
25+
```typescript
26+
import { Client } from "@upstash/qstash";
27+
28+
const client = new Client({ devMode: true });
1529

16-
## NPX (Node Package Executable)
30+
await client.publishJSON({
31+
url: "https://example.com/webhook",
32+
body: { hello: "world" },
33+
});
34+
```
35+
36+
```typescript
37+
// app/api/webhook/route.ts
38+
import { verifySignatureAppRouter } from "@upstash/qstash/nextjs";
39+
40+
export const POST = verifySignatureAppRouter(
41+
async (request) => {
42+
// signed by the local dev server
43+
return new Response("ok");
44+
},
45+
{ devMode: true }
46+
);
47+
```
48+
49+
On startup the SDK prints the dev server URL and a link to the Upstash Console:
50+
51+
```
52+
[QStash Dev] Server running at http://127.0.0.1:8080
53+
Console: https://console.upstash.com/qstash/local-mode-user?port=8080
54+
```
55+
56+
When dev mode is active, the SDK will:
57+
58+
- Download the latest `qstash` binary on first use, cached in your OS cache directory:
59+
- macOS: `~/Library/Caches/upstash/qstash-dev`
60+
- Linux: `~/.cache/upstash/qstash-dev`
61+
- Windows: `%LOCALAPPDATA%\upstash\qstash-dev`
62+
- Spawn the server on port `8080` (override with `QSTASH_DEV_PORT`).
63+
- Confirm the server is running on the configured port and skip spawning if it is.
64+
- Override the `baseUrl`, `token`, and signing keys you provide and use the dev server's instead.
65+
66+
<Warning>
67+
Dev mode is automatically a no-op when `NODE_ENV=production` and in browser/edge runtimes.
68+
</Warning>
69+
70+
### Next.js edge routes
71+
72+
If you are using edge routes in Next.js, the SDK cannot spawn the dev server from the edge runtime — it can only verify it is reachable. To start the server before any edge request hits, call `registerQStashDev()` from `instrumentation.ts`:
73+
74+
```typescript
75+
// instrumentation.ts
76+
import { registerQStashDev } from "@upstash/qstash/nextjs";
77+
78+
export const register = () => registerQStashDev();
79+
```
80+
81+
## Running the dev server manually
82+
83+
If you would rather run the dev server manually (Python, Go, plain HTTP, etc.), use the QStash CLI directly.
84+
85+
### @upstash/qstash-cli
1786

1887
Install the binary via the `@upstash/qstash-cli` NPM package:
1988

@@ -31,7 +100,7 @@ Once you start the local server, you can go to the QStash tab on Upstash Console
31100

32101
<img src="/img/qstash/local-mode-qstash.png" />
33102

34-
## Docker
103+
### Docker
35104

36105
QStash CLI is available as a Docker image through our public AWS ECR repository:
37106

@@ -43,7 +112,7 @@ docker pull public.ecr.aws/upstash/qstash:latest
43112
docker run -p 8080:8080 public.ecr.aws/upstash/qstash:latest qstash dev
44113
```
45114

46-
## Artifact Repository
115+
### Direct download
47116

48117
You can download the binary directly from our artifact repository without using a package manager:
49118

@@ -56,7 +125,7 @@ After extracting the archive file, run the executable:
56125
$ ./qstash dev
57126
```
58127

59-
## QStash CLI
128+
## CLI reference
60129

61130
Currently, the only available command for QStash CLI is `dev`, which starts a development server instance.
62131

@@ -83,6 +152,8 @@ Running `qstash dev` starts two components:
83152
$ ./qstash dev -port=8080 -log-port=9000
84153
```
85154

155+
## Test users
156+
86157
There are predefined test users available. You can configure the quota type of users using the `-quota` option, with available options being `payg` and `pro`.
87158
These quotas don't affect performance but allow you to simulate different server limits based on the subscription tier.
88159

@@ -121,8 +192,6 @@ QSTASH_NEXT_SIGNING_KEY="sig_7GFR4YaDshFcqsxWRZpRB161jguD"
121192

122193
</CodeGroup>
123194

124-
<Info>Currently, there is no GUI client available for the development server. You can use QStash SDKs to fetch resources like event logs.</Info>
125-
126195
## License
127196

128197
The QStash development server is licensed under the [Development Server License](/qstash/misc/license), which restricts its use to development and testing purposes only.

qstash/sdks/ts/gettingstarted.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ const client = new Client({
4646
});
4747
```
4848

49+
## Local development
50+
51+
Pass `devMode: true` (or set `QSTASH_DEV=true`) to have the SDK download, start, and manage a local QStash dev server for you. No tokens or signing keys required — the SDK injects deterministic dev credentials.
52+
53+
```typescript
54+
import { Client } from "@upstash/qstash";
55+
56+
const client = new Client({ devMode: true });
57+
```
58+
59+
The same flag works on the receiving side — pass `devMode: true` to `Receiver` or `verifySignature*` to verify signatures with the dev server's keys. See [Local Development](/qstash/howto/local-development) for the full walkthrough, including the `registerQStashDev()` helper for Next.js edge routes.
60+
4961
## Telemetry
5062

5163
This sdk sends anonymous telemetry headers to help us improve your experience.

workflow/howto/local-development/development-server.mdx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,40 @@ title: "Development Server"
55
Upstash Workflow is built on top of Upstash QStash.
66
The QStash CLI provides a local development server that performs QStash functionality locally for development and testing purposes.
77

8+
## Automatic dev server (recommended)
9+
10+
If you are using `@upstash/workflow`, you can just set `QSTASH_DEV=true` in your environment, and the SDK will download and connect to the dev server automatically. No tokens or signing keys required.
11+
12+
```bash .env
13+
QSTASH_DEV=true
14+
```
15+
16+
With `QSTASH_DEV=true` set, both the workflow client and the `serve()` endpoint pick up the dev server automatically. The endpoint also verifies incoming signatures against the dev server's deterministic signing keys, so signature verification works end-to-end with no extra setup.
17+
18+
```typescript
19+
// app/api/workflow/route.ts
20+
import { serve } from "@upstash/workflow/nextjs";
21+
22+
export const { POST } = serve(async (context) => {
23+
await context.run("step-1", () => console.log("running locally"));
24+
});
25+
```
26+
27+
```typescript
28+
import { Client } from "@upstash/workflow";
29+
30+
const client = new Client({ token: process.env.QSTASH_TOKEN ?? "" });
31+
32+
await client.trigger({
33+
url: "http://localhost:3000/api/workflow",
34+
});
35+
```
36+
37+
For details on the dev server behavior, ports, and the `registerQStashDev()` helper for Next.js edge routes, see the [QStash Local Development docs](/qstash/howto/local-development).
38+
39+
## Manual setup
40+
41+
If you would rather start and manage the QStash dev server yourself, follow the steps below.
842

943
<Steps>
1044
<Step title="Install and Start Development Server">

0 commit comments

Comments
 (0)