This tutorial uses Redis as state store for a Nuxt.js application. We simply increment a counter that pulls the data from Redis.
1 Create Nuxt.js Project#
Run this in terminal
2 Set up environment variables#
.env.example file in this directory to
REDIS_URL: Copy the url in the database page of the Upstash console
Create a database as getting started
3 Server Middleware#
We will write a Nuxt middleware which increments a counter in Redis and returns its new value.
Now we will configure the middleware in nuxt.config.js
Go to http://localhost:3000/
- For best performance the application should run in the same region with the Redis database's region.