upstash-qstash-js
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQStash JavaScript SDK
QStash JavaScript SDK
QStash is an HTTP-based messaging and scheduling solution for serverless and edge runtimes. This skill helps you use the QStash JS SDK effectively.
QStash是一款面向无服务器和边缘运行时的基于HTTP的消息传递与调度解决方案。本技能可帮助你高效使用QStash JS SDK。
When to use this skill
何时使用本技能
Use this skill when:
- Publishing HTTP messages to endpoints or URL groups
- Creating scheduled or delayed message delivery
- Managing FIFO queues with configurable parallelism
- Verifying incoming webhook signatures from QStash
- Implementing callbacks, DLQ handling, or message deduplication
在以下场景使用本技能:
- 向端点或URL组发布HTTP消息
- 创建定时或延迟消息投递
- 管理可配置并行度的FIFO队列
- 验证来自QStash的传入Webhook签名
- 实现回调、死信队列(DLQ)处理或消息去重
Quick Start
快速开始
Installing the SDK
安装SDK
bash
npm install @upstash/qstashbash
npm install @upstash/qstashBasic Publishing
基础发布
typescript
import { Client } from "@upstash/qstash";
const client = new Client({
token: process.env.QSTASH_TOKEN!,
});
const result = await client.publishJSON({
url: "https://my-api.example.com/webhook",
body: { event: "user.created", userId: "123" },
});typescript
import { Client } from "@upstash/qstash";
const client = new Client({
token: process.env.QSTASH_TOKEN!,
});
const result = await client.publishJSON({
url: "https://my-api.example.com/webhook",
body: { event: "user.created", userId: "123" },
});Core Concepts
核心概念
For fundamental QStash operations, see:
- Publishing Messages
- Schedules
- Queues and Flow Control
- URL Groups
For verifying incoming messages:
- Receiver Verification - Core signature verification with the Receiver class
- Platform-Specific Verifiers:
- Next.js - App Router, Pages Router, and Edge Runtime
For advanced features:
- Callbacks
- Dead Letter Queue (DLQ)
- Message Deduplication
- Region migration & multi-region support
- If needed, multi-region env variable setup verification script. Can be run without arguments
如需了解QStash的基础操作,请查看:
- 发布消息
- 调度
- 队列与流量控制
- URL组
如需验证传入消息:
- 接收方验证 - 使用Receiver类进行核心签名验证
- 平台特定验证器:
- Next.js - App Router、Pages Router和Edge Runtime
如需使用高级功能:
- 回调
- 死信队列(DLQ)
- 消息去重
- 区域迁移与多区域支持
- 如有需要,可使用多区域环境变量设置验证脚本,无需参数即可运行
Platform Support
平台支持
QStash JS SDK works across various platforms:
- Next.js (App Router and Pages Router)
- Cloudflare Workers
- Deno
- Node.js (v18+)
- Vercel Edge Runtime
- SvelteKit, Nuxt, SolidJS, and other frameworks
Note on Workflow SDK: For building complex durable workflows that chain multiple QStash messages together, consider using the separate QStash Workflow SDK (). The Workflow SDK empowers you to orchestrate multi-step processes with automatic state management, retries, and fault tolerance. This Skills file focuses on the core QStash messaging SDK.@upstash/workflow
QStash JS SDK支持多种平台:
- Next.js(App Router和Pages Router)
- Cloudflare Workers
- Deno
- Node.js(v18+)
- Vercel Edge Runtime
- SvelteKit、Nuxt、SolidJS及其他框架
Workflow SDK说明: 如需构建将多个QStash消息链接在一起的复杂持久化工作流,可考虑使用独立的QStash Workflow SDK()。该Workflow SDK支持你编排多步骤流程,并提供自动状态管理、重试和容错能力。本技能文档聚焦于核心QStash消息传递SDK。@upstash/workflow
Best Practices
最佳实践
- Always verify incoming QStash messages using the Receiver class
- Use environment variables for tokens and signing keys
- Set appropriate retry counts and timeouts for your use case
- Use queues for ordered processing with controlled parallelism
- Implement DLQ handling for failed message recovery
- 始终使用Receiver类验证传入的QStash消息
- 使用环境变量存储令牌和签名密钥
- 根据你的使用场景设置合适的重试次数和超时时间
- 使用队列进行有序处理并控制并行度
- 实现DLQ处理以恢复失败的消息