2 min read

Run Apps with Serverless Redis

Enes Akar

Cofounder @Upstash Setup
Upstash Redis Setup
Application Code
Run and Deploy
Closing Words is a great platform where you can distribute your application globally. When your application is global, your data needs to be global. You can run regular Redis as a app but the problem is it is located in a single region. On the other hand, Upstash Redis Global Database perfectly fits as it is globally replicated. Moreover, thanks to its REST based SDK, it does not have any connection problem in stateless runtime.

In this article, I will create a basic Node.js application which accesses Upstash Redis and deploy it to platform. Setup

  • Create a account.
  • Install flyctl and run flyctl auth login

Upstash Redis Setup

  • Create a free Global Database on Upstash Console
  • Copy the REST_URL and REST_TOKEN, you will use them in the next step.

Application Code

  • Clone the hello world app: git clone
  • Install dependencies: npm install express @upstash/redis
  • Update the server.js and replace url and token:
const express = require("express");
const app = express();
const port = process.env.PORT || 3000;
const { Redis } = require("@upstash/redis");

const redis = new Redis({
  url: "REPLACE_HERE",
  token: "REPLACE_HERE",

app.get(["/", "/:name"], async (req, res) => {
  let greeting = "<h1>Hello From Node on Fly!</h1>";
  if (req.url !== "/favicon.ico") {
    const data = await redis.incr("count");
    res.send(greeting + "</br> Counter: " + data);
  } else {

app.listen(port, () => console.log(`HelloNode app listening on port ${port}!`));

Run and Deploy

  • Run the application locally: node server.js

  • Launch and deploy to flyctl launch

  • You can redeploy your app with flyctl deploy

  • See your applications url with flyctl status

  • You can also check your application from dashboard:

Closing Words

In this article, we have showcased how to use Upstash Redis on application platform.

Feel free to reach out us on GitHub , Discord and Twitter for any issues or comments.

© 2023 Upstash, Inc. Based in California.

* Redis is a trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by Upstash is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and Upstash.

** Cloudflare, the Cloudflare logo, and Cloudflare Workers are trademarks and/or registered trademarks of Cloudflare, Inc. in the United States and other jurisdictions.