Registry / storage / fastify-redis-session

fastify-redis-session

JSON →
library2.0.0jsnpmunverified

Redis store for fastify-session using ioredis. Current stable version is 2.0.0, released 2020-12-14. It integrates with @mgcrea/fastify-session to provide Redis-backed session storage for Fastify applications. Differentiators: uses ioredis (modern Redis client with Cluster/Sentinel support), ships TypeScript definitions, lightweight store implementation. Alternative to connect-redis for Koa/Express ecosystems. Release cadence is low; last release over 3 years ago.

storage
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Named export; not default. Works in both ESM and CJS contexts due to TypeScript compilation.

import { RedisStore } from 'fastify-redis-session'

Type is re-exported from fastify-session, not from this package.

import { FastifySessionOptions } from '@mgcrea/fastify-session'

TypeScript allows extracting type separately; not required but reduces bundle.

import type { RedisStore } from 'fastify-redis-session'

Sets up a Fastify server with Redis-backed session storage using fastify-redis-session.

import fastify from 'fastify'; import fastifyCookie from 'fastify-cookie'; import fastifySession from '@mgcrea/fastify-session'; import Redis from 'ioredis'; import { RedisStore } from 'fastify-redis-session'; const app = fastify(); app.register(fastifyCookie); app.register(fastifySession, { store: new RedisStore({ client: new Redis('redis://localhost:6379'), ttl: 86400 }), secret: 'a secret with minimum length of 32 characters', cookie: { maxAge: 86400 }, }); app.get('/', (request, reply) => { request.session.views = (request.session.views || 0) + 1; reply.send({ views: request.session.views }); }); app.listen(3000);
Debug
Known footguns
breakingVersion 2.0.0 changed the export from default to named export.
deprecatedfastify-cookie is deprecated; use @fastify/cookie instead.
gotchaThe `secret` option in fastify-session must be at least 32 characters long, else session will fail silently.
gotchaRedisStore expects a `client` option; if you pass an existing Redis client without proper connection, session storage will fail.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
20 hits · last 30 days
gptbot
3
amazonbot
3
bytedance
3
dotbot
1
ahrefsbot
1
Resources