Registry / storage / svelte-kit-connect-redis

svelte-kit-connect-redis

JSON →
library0.1.0jsnpmunverified

Redis session storage adapter for svelte-kit-sessions, version 0.1.0. Designed specifically for SvelteKit applications, it provides a custom store implementation that integrates with either the `redis` or `ioredis` client. Unlike generic connect-redis adapters, this package is tailored for SvelteKit's session handling pattern via `svelte-kit-sessions`. Currently in early release, it supports configurable key prefixes, custom serializers, and TTL overrides. Ships with TypeScript definitions.

npm install svelte-kit-connect-redis
INSTALL
IMPORT
SIG · SVELTE-KIT-CONNECT
S
svelte-kit-connect-redis
storagejavascriptv0.1.0
harness data pending
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.

RedisStore
import RedisStore from 'svelte-kit-connect-redis';
import { RedisStore } from 'svelte-kit-connect-redis';
Default export only, not a named export. Common mistake due to similar packages.
sveltekitSessionHandle
import { sveltekitSessionHandle } from 'svelte-kit-sessions';
import sveltekitSessionHandle from 'svelte-kit-sessions';
Named export from the peer dependency 'svelte-kit-sessions', not this package.
createClient (redis) or Redis (ioredis)
import { createClient } from 'redis'; or import { Redis } from 'ioredis';
Choose one client library. The client instance must be connected before passing to RedisStore.

Sets up Redis-based session storage for SvelteKit using svelte-kit-sessions and svelte-kit-connect-redis with the redis client.

// src/hooks.server.ts import type { Handle } from '@sveltejs/kit'; import { sveltekitSessionHandle } from 'svelte-kit-sessions'; import RedisStore from 'svelte-kit-connect-redis'; import { createClient } from 'redis'; const client = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }); await client.connect(); export const handle: Handle = sveltekitSessionHandle({ secret: process.env.SESSION_SECRET ?? 'change-me', store: new RedisStore({ client }), // Optional configuration // prefix: 'sess:', // ttl: 86400 }); console.log('Redis session store initialized');
Debug
Known issues
gotchaClient must be connected before passing to RedisStore; otherwise, session store operations will fail silently.
fix
Ensure `await client.connect()` is called before creating `new RedisStore({ client })`.
affects: >=0.1.0
gotchaWhen using ioredis, the client instance must be compatible; ensure you pass the correct type. Mixing redis and ioredis clients will cause runtime errors.
fix
Use only one Redis client library and pass the appropriate instance to RedisStore.
affects: >=0.1.0
gotchaThe default serializer uses JSON.parse/stringify; custom serializers must handle both encode and decode consistently.
fix
If providing a custom serializer, ensure it implements both `parse` and `stringify` methods.
affects: >=0.1.0
deprecatedPackage is very early (v0.1.0); API may change without major version bump. No breaking change policy guaranteed.
fix
Pin exact version and monitor releases for breaking changes.
affects: >=0.1.0 <1.0.0
Errors
Common errors & fixes
TypeError: client.connect is not a function
Attempting to connect a Redis client that was already connected or using an incompatible client instance.
fix
Ensure you call `client.connect()` only once and pass the connected client. Example: `const client = createClient(); await client.connect();`
Error: The client must be a redis or ioredis client
Passing a client that is not an instance of redis client or ioredis client.
fix
Use either `createClient()` from 'redis' or `new Redis()` from 'ioredis' and pass the instance directly.
ERR wrong number of arguments for 'get' command
Corrupted session key or serialized data causing malformed Redis commands.
fix
Check the key prefix configuration and ensure serialization consistency. Default prefix is 'sess:'.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
svelte-kit-sessionsrequiredCore session middleware required to use this store adapter
redisoptionalOptional Redis client if using the `redis` package (choose one of `redis` or `ioredis`)
ioredisoptionalOptional Redis client if using the `ioredis` package (choose one of `redis` or `ioredis`)
Agent activity
34 hits · last 30 days
node
32
OpenAI (training)
1
Resources
svelte-kit-connect-redis — npm install svelte-kit-connect-redis · libregistry