@thor-commerce/thor-app-session-storage-d1
v0.1.0
Published
Cloudflare D1 session storage for Thor Commerce apps
Readme
@thor-commerce/thor-app-session-storage-d1
Cloudflare D1-backed session storage for Thor Commerce apps.
pnpm add @thor-commerce/thor-app-session-storage-d1Create a D1 database and bind it to your Worker:
{
"d1_databases": [
{
"binding": "THOR_SESSIONS",
"database_name": "thor-app-sessions",
"database_id": "<database-id>"
}
]
}Copy the included schema.sql into your D1 migrations (or use the SQL returned
by getD1SessionTableSql()), apply it, then pass the binding to Thor:
import {env} from "cloudflare:workers";
import {D1SessionStorage} from "@thor-commerce/thor-app-session-storage-d1";
import {thorApp} from "@thor-commerce/thor-app-react-router/server";
const thor = thorApp({
// ...
sessionStorage: new D1SessionStorage(env.THOR_SESSIONS),
});For local prototypes, await sessionStorage.initialize() can create the table
without a migration. Prefer a migration for production deployments.
