This tutorial implements an autocomplete API powered by serverless Redis. See the demo and API endpoint and the source code.

We will keep country names in a Redis Sorted set. In Redis sorted sets, elements with the same score are sorted lexicographically. So in our case, all country names will have the same score, 0. We keep all prefixes of country and use ZRANK to find the terms to suggest. See this blog post for the details of the algorithm.

Step 1: Project Setup

If you do not have it already install the serverless framework via: npm install -g serverless

In any folder run…


Designing a database for serverless, the biggest challenge in our mind was to build an infrastructure which supports per request pricing in a profitable way. We believe Upstash has achieved this. After we launched the product, we saw that there was another major challenge: Database connections!

As you know, Serverless Functions scale from 0 to infinity. This means when your functions get a lot of traffic, the cloud provider creates new containers (lambda functions) in parallel and scales out your backend. …


We’re excited to announce Upstash now supports a GraphQL API for connecting to Serverless Redis. Now, you can connect to Upstash wherever you can send HTTP requests (including WebAssembly and mobile apps).

Until now, the only way to connect to your database was with the Redis protocol which requires TCP connection. GraphQL helps you with database connection limits especially in serverless environments. Further, using GraphQL enables Upstash to provide features and APIs that Redis doesn’t support natively.

The GraphQL API opens up new possibilities with Redis, but it does not replace the Redis protocol. Using Redis directly will have lower…


This tutorial shows how to use Serverless Redis as your session storage for your Express Applications.

See the Github repo.

Step-1: Create Project

Create a folder for your project and run: npm init

Step-2: Install Redis and Express

In your project folder run: npm install express redis connect-redis express-session

Step-3: Create a Redis (Upstash) Database For Free

Create a database as described here.

Step-4: index.js

In Upstash console, click the Connect button, copy the connection code (Node.js node-redis). Create index.js file as below and replace the Redis connection part.

var express = require('express') var parseurl = require('parseurl') var session = require('express-session') const redis = require('redis') var RedisStore = require('connect-redis')(session) var client = redis.createClient ({ // REPLACE HERE })…


In this tutorial we will write a single page application which uses Redis as state store in a Next.js application.

The example is a basic roadmap voting application where users enter and vote for feature requests. You can check the complete application in Upstash Roadmap page

Deploy Yourself

You can check the source code of the complete application here. Thanks to Upstash&Vercel integration, you can deploy the application yourself with zero cost and code by clicking Deploy with Vercel.

Create Next.js Project

We will use Next.js as web framework. So let’s create a next.js app and install the redis client first.

npx create-next-app nextjs-with-redis

npm…


This tutorial shows how to build a serverless API for Page View Counter with Python and Redis. The API will the count page views and show it in JSON format.

Stack:

  • Serverless compute: AWS Lambda (Python)
  • Serverless data store: Redis via Upstash
  • Deployment tool: AWS SAM

Prerequisites:

  • An AWS account for AWS Lambda functions.
  • Install AWS SAM CLI tool as described here to create and deploy the project.
  • An Upstash account for serverless Redis.

Step 1: Init the Project

Run the sam init and then

  • Select AWS Quick Start Templates
  • Select 2 — python3.8
  • Enter your project name: python-redis-example
  • Select 1 — Hello World Example SAM will…


This tutorial shows you how to build a serverless API with Golang and Redis. The API will simply the count page views and show it in JSON format.

Stack:

  • Serverless compute: AWS Lambda (Golang)
  • Serverless data store: Redis via Upstash
  • Deployment tool: AWS SAM

Prerequisites:

  • An AWS account for AWS Lambda functions.
  • Install AWS SAM CLI tool as described here to create and deploy the project.
  • An Upstash account for serverless Redis.

Run the `sam init` and then

  • Select AWS Quick Start Templates
  • Select 4 — go1.x
  • Enter your project name: go-redis-example
  • Select 1 — Hello World Example SAM will generate your…


In this tutorial I will showcase Redis as the state store for a Next.js application. We simply add a counter that pulls the data from Redis.

See code and demo.

Step-1: Create Next.js Project

npx create-next-app nextjs-with-redis

Step-2: Create a Redis (Upstash) Database

  • Create a database as described here.
  • Install Redis client (ioredis) via npm install ioredis

Step-3: Update the Next.js App

  • Copy the url in the database page Upstash console.
  • Update the index.js as below (replace YOUR_REDIS_ENDPOINT):
import Head from 'next/head' import styles from '../styles/Home.module.css' import Redis from 'ioredis' export default function Home({ data }) { return ( <div className={styles.container}> <Head> <title>Create Next App</title> <link rel="icon" href="/favicon.ico" /> </Head> <main className={styles.main}> <h1 className={styles.title}> Welcome…

Noah Fischer

DevRel @upstash

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store