SQLiteStateStore
SQLiteStateStore provides a State Store using local SQLite databases with support for multiple SQLite engines including Bun SQLite, better-sqlite3, and libSQL.
-
Configure SQLiteStateStore
Update your
alchemy.run.ts
to use local SQLite state storage:import alchemy from "alchemy";import { SQLiteStateStore } from "alchemy/sqlite";const app = await alchemy("my-app", {stateStore: (scope) => new SQLiteStateStore(scope)});// Your resources here...await app.finalize(); -
Run your app
Execute your Alchemy script to initialize the SQLite state store:
Terminal window bun ./alchemy.run.tsTerminal window npx tsx ./alchemy.run.tsTerminal window pnpm tsx ./alchemy.run.tsTerminal window yarn tsx ./alchemy.run.tsAlchemy automatically creates a SQLite database at
.alchemy/state.sqlite
. -
Verify the state store
Check that the database file was created:
Terminal window ls -la .alchemy/# You should see state.sqlite -
View in your editor
Most IDEs can view the SQLite database file directly.