npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@upstash/workflow

v0.2.23

Published

Durable, Reliable and Performant Serverless Functions

Readme

Upstash Workflow SDK

npm (scoped)

[!NOTE]
This project is in GA Stage. The Upstash Professional Support fully covers this project. It receives regular updates, and bug fixes. The Upstash team is committed to maintaining and improving its functionality.

Upstash Workflow lets you write durable, reliable and performant serverless functions. Get delivery guarantees, automatic retries on failure, scheduling and more without managing any infrastructure.

See the documentation for more details

Quick Start

Here, we will briefly showcase how you can get started with Upstash Workflow.

Alternatively, you can check our quickstarts for different frameworks, including Next.js and Cloudflare.

Install

First, install the package with:

npm install @upstash/workflow

Get QStash token

Go to Upstash Console and copy the QSTASH_TOKEN.

Define a Workflow Endpoint

To declare workflow endpoints, use the serve method:

import { serve } from "@upstash/workflow/nextjs";

// mock function
const someWork = (input: string) => {
  return `processed '${JSON.stringify(input)}'`;
};

// serve endpoint which expects a string payload:
export const { POST } = serve<string>(async (context) => {
  // get request body:
  const input = context.requestPayload;

  // run the first step:
  const result1 = await context.run("step1", async () => {
    const output = someWork(input);
    console.log("step 1 input", input, "output", output);
    return output;
  });

  // run the second step:
  await context.run("step2", async () => {
    const output = someWork(result1);
    console.log("step 2 input", result1, "output", output);
  });
});

In the example, you can see that steps are declared through the context object.

The kinds of steps which are available are:

  • context.run: execute a function
  • context.sleep: sleep for some time
  • context.sleepUntil: sleep until some timestamp
  • context.call: make a third party call without consuming any runtime
  • context.waitForEvent: wait for an event
  • context.notify: notify an event to make workflows waiting for the event continue

You can learn more about these methods from our documentation.

Workflow Client

You can use the Upstash Workflow client to cancel workflows, notify workflows waiting for an event or get the workflows waiting for an event:

import { Client } from "@upstash/workflow";
const client = new Client({ token: "<QSTASH_TOKEN>" });

// trigger a workflow
const { workflowRunId } = await client.trigger({
  url: "https://workflow-endpoint.com",
  body: "hello there!",         // Optional body
  headers: { ... },             // Optional headers
  workflowRunId: "my-workflow", // Optional workflow run ID
  retries: 3                    // Optional retries for the initial request
});

// cancel workflow:
await client.cancel({ workflowRunId: "<WORKFLOW_RUN_ID>" });

// notify workflows:
await client.notify({
  eventId: "my-event-id",
  eventData: "my-data", // data passed to the workflow run
});

// get waiters:
const result = await client.getWaiters({
  eventId: "my-event-id",
});

Telemetry

This sdk sends anonymous telemetry headers to help us improve your experience. We collect the following:

You can opt out by setting disableTelemetry: true when triggering the workflow and in the serve options:

// client
const client = new Client(/***/);
await client.trigger({
  // ...
  disableTelemetry: true,
});

// workflow endpoint
export const { POST } = serve(
  async (context) => {
    // ...
  },
  {
    disableTelemetry: true,
  }
);

Contributing

Setup

This project requires Bun to be installed. Please see the Bun installation documentation for further instructions.

Once you have cloned the project, you will need to install the dependencies and then you can run the project.

bun install
bun run build

Testing

To begin testing, environment variables will need to be setup. First, create a .env file in the root of the project. .env.template can be used as a template. Your values can be found in the Qstash Console.

bun run test