Overview
Where A2 keeps your session histories.
import { createServer } from 'experimental-a2/server'
import { redis } from 'experimental-a2/store-redis'
import { orders } from '@/contracts'
export const ordersServer = createServer({
contract: orders,
store: redis({ url: process.env.REDIS_URL }),
handlers: {
/* ... */
},
})| Store | Use it for |
|---|---|
| Redis | Production (recommended) |
| Redis over HTTP | Production, when your provider only offers a REST API |
| Postgres | Production |
| SQLite | Development: the default |
| Memory | Tests: the default when NODE_ENV=test |
When you omit store, development gets SQLite, so state survives next dev
restarts, and tests get memory. Production has no default, on purpose: the
server throws STORE_NOT_CONFIGURED at startup rather than write events to a
filesystem that evaporates.
A store holds A2's session histories. It doesn't connect A2 to your application tables; see Sessions and your database.
Servers with handlers or timers also need a scheduler.