Documentation
Overview
A multi-game leaderboard service you can stand up in minutes. This page covers the concepts and the quick start; the guides go deeper.
The service stores scores in TursoDB and exposes a small JSON API. Games authenticate with a per-game bearer key. There are no player accounts: the game is trusted to report scores for the players it knows about.
Core concepts
A request with game A's key can never read or write game B's boards — asking for another game's board returns 404 rather than leaking its existence.
Quick start
1. Create the database
Create a Turso database and note its URL and an auth token. Skip this if you just want to try things locally — a file: URL works too.
# Create a Turso database and grab its URL + token.
turso db create leaderboard
turso db show leaderboard --url # libsql://...
turso db tokens create leaderboard # auth token2. Configure the environment
Copy the example env file and fill in your credentials.
TURSO_DATABASE_URL=libsql://your-db.turso.io
TURSO_AUTH_TOKEN=your-tokenFor local development without Turso:
# Or develop locally against a plain file.
TURSO_DATABASE_URL=file:leaderboard.db3. Apply the schema and create a game
This creates the tables, registers a game, and prints its API key exactly once. Store it somewhere safe.
npm install
npm run db:init
npm run admin game:create "Space Blaster"
npm run dev4. Make a request
The API key is the only credential. Send it as a bearer token on every call.
/api/leaderboardscurl -H "Authorization: Bearer lgb_..." \
http://localhost:3000/api/leaderboardsDeploy to Vercel
Push the repository to GitHub and import it into Vercel. Add TURSO_DATABASE_URL and TURSO_AUTH_TOKEN as environment variables, then deploy. Run the admin CLI from your machine pointing at the same Turso database to create games and boards.
Next steps
Both guides assume the API is deployed and you have a game key. See the quick start if you need one.