Skip to content
GitHubXDiscord

SQLiteStateStore

SQLiteStateStore provides a State Store using local SQLite databases with support for multiple SQLite engines including Bun SQLite, better-sqlite3, and libSQL.

  1. 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();
  2. Run your app

    Execute your Alchemy script to initialize the SQLite state store:

    Terminal window
    bun ./alchemy.run.ts

    Alchemy automatically creates a SQLite database at .alchemy/state.sqlite.

  3. Verify the state store

    Check that the database file was created:

    Terminal window
    ls -la .alchemy/
    # You should see state.sqlite
  4. View in your editor

    Most IDEs can view the SQLite database file directly.

    SQLite State Store