home / skills / upstash / qstash-js / skills

skills skill

/skills

This skill helps you publish HTTP messages, schedule deliveries, and manage queues with the QStash JS SDK for serverless apps.

npx playbooks add skill upstash/qstash-js --skill skills

Review the files below or copy the command above to add this skill to your agents.

Files (12)
SKILL.md
2.9 KB
---
name: qstash-js
description: Work with the QStash JavaScript/TypeScript SDK for serverless messaging, scheduling. Use when publishing messages to HTTP endpoints, creating schedules, managing queues, verifying incoming messages in serverless environments.
---

# 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.

## 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

## Quick Start

### Installing the SDK

```bash
npm install @upstash/qstash
```

### Basic 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" },
});
```

## Core Concepts

For fundamental QStash operations, see:

- [Publishing Messages](fundamentals/publishing-messages.md)
- [Schedules](fundamentals/schedules.md)
- [Queues and Flow Control](fundamentals/queues-and-flow-control.md)
- [URL Groups](fundamentals/url-groups.md)

For verifying incoming messages:

- [Receiver Verification](verification/receiver.md) - Core signature verification with the Receiver class
- Platform-Specific Verifiers:
  - [Next.js](verification/platform-specific/nextjs.md) - App Router, Pages Router, and Edge Runtime

For advanced features:

- [Callbacks](advanced/callbacks.md)
- [Dead Letter Queue (DLQ)](advanced/dlq.md)
- [Message Deduplication](advanced/deduplication.md)
- [Region migration & multi-region support](advanced/multi-region.md)
  - If needed, [multi-region env variable setup verification script](advanced/multi-region/verify-multi-region-setup.ts). Can be run without arguments

## 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 (`@upstash/workflow`). 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.

## 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

Overview

This skill explains how to use the QStash JavaScript/TypeScript SDK to publish HTTP messages, create schedules, manage queues, and verify incoming webhook signatures in serverless or edge environments. It focuses on practical usage patterns, supported platforms, and integration points for reliable message delivery and processing. The content highlights when to use publishing, scheduling, FIFO queues, and receiver verification.

How this skill works

The SDK exposes a Client for publishing JSON or raw payloads to HTTP endpoints or URL groups, and a Receiver utility to verify incoming QStash signatures. It supports schedule creation, delayed delivery, FIFO queues with configurable parallelism, callbacks, and DLQ management. The library runs in Node, edge runtimes (Vercel, Cloudflare), Deno, and common frameworks like Next.js and SvelteKit. Use environment variables for tokens and signing keys and the SDK methods for publish, schedule, and queue operations.

When to use it

  • Publish HTTP messages to third-party or internal endpoints reliably from serverless functions
  • Create scheduled tasks or delayed job delivery without maintaining a separate scheduler
  • Process ordered workloads with FIFO queues and controlled concurrency
  • Verify incoming webhook requests from QStash to ensure authenticity
  • Implement callbacks, dead-letter queues, or deduplication for robust message handling

Best practices

  • Always verify incoming messages using the Receiver class and signing key stored in environment variables
  • Keep QStash tokens and signing keys in secure environment variables, never in source code
  • Set sensible retry counts, timeouts, and use DLQ for persistent failures
  • Use queues plus limited parallelism to maintain order and avoid overloading downstream systems
  • Prefer URL groups for broadcasting to multiple endpoints and use schedules for recurring tasks

Example use cases

  • Send user-created events to a webhook reliably from an API route or edge function
  • Schedule nightly report generation or email digests with delayed message delivery
  • Create an ordered task queue for image processing with parallelism set to match workers
  • Verify QStash-sent webhooks in a Next.js or Cloudflare Worker using Receiver before processing
  • Route failed messages to a DLQ and implement a retry-and-inspect workflow for debugging

FAQ

How do I verify incoming QStash webhooks?

Use the Receiver class with your signing key to validate the signature header before processing the payload.

Which platforms are supported?

The SDK supports Node.js (v18+), Vercel Edge, Cloudflare Workers, Deno, Next.js, SvelteKit, Nuxt and other serverless/edge frameworks.