Image for post
Image for post

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 })…

Image for post
Image for post

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…


Image for post
Image for post

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…


Image for post
Image for post

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…


Image for post
Image for post

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