Bash.tv → GitHub → itch.io

← Services · Home

Supabase: Database, Logins & Leaderboards That Work Everywhere

Supabase is a hosted database (Postgres) with logins, file storage, and an instant API. Use it when a game needs saves, leaderboards, or accounts that work outside Bash, like on itch.io, Newgrounds, or your own site.

   
Cost Free plan: 2 projects, which pause after a week without activity
Needs a Bash API key? Only for the bot to manage data from Bash (the secret key). The game uses the publishable key
Good for Global leaderboards, cloud saves, player accounts, level sharing

Inside Bash, you may not need this. Bash spaces already have built-in shared saves, leaderboards, and multiplayer rooms. Supabase is for when the game is played somewhere else.


The two keys (important)

Key Looks like Where it goes Power
Publishable sb_publishable_... In the game (safe to be public) Only what your Row Level Security rules allow
Secret sb_secret_... Never in the game. Only in Bash’s key settings or server code Full access, ignores all rules

The older anon / service_role keys work the same way, but Supabase is retiring them in early 2027. Use the new ones.


Part 1: Create a project

  1. Sign up at https://supabase.com/dashboard.
  2. New project → name, database password (save it somewhere), and region → Create.
  3. Open Project Settings → API Keys and copy:
    • the Project URL: https://<project-ref>.supabase.co
    • the publishable key
    • the secret key, only if the bot will manage data from Bash

Part 2: Let the game use it (publishable key)

Ask the bot:

Add a global leaderboard with Supabase. Project URL https://abcd.supabase.co, publishable key sb_publishable_….

The publishable key is designed to be public, so it’s fine in the chat. The bot will:

  1. Write the SQL for a scores table with Row Level Security turned on, for example “anyone can read; anyone can insert a score; nobody can edit or delete”.
  2. Ask you to run it in SQL Editor in the dashboard, unless it has the secret key (Part 3).
  3. Add @supabase/supabase-js to the game and post and read scores.

Always keep Row Level Security on. Without it, the publishable key lets anyone change everything. Scores sent from a browser can be faked. For serious competitions, check scores in an Edge Function (the bot can write one).

Part 3 (optional): Let the bot manage data from Bash (secret key)

Gear icon → API keys → Any API

Field Value
Address <project-ref>.supabase.co
Name Supabase
Key the secret key (sb_secret_...)
How it’s sent A custom header named apikey, with the key as the whole value (no Bearer). Supabase needs this header
Tips for the bot Supabase secret key for project <ref>. Never put it in game code. Keep RLS on every table.

Then the bot can create tables, view data, and clear test scores from Bash.

If the Bash form has no custom-header option, skip this part. Run the SQL yourself in the dashboard’s SQL Editor. The game side (Part 2) works either way.


Troubleshooting

Problem Fix
401 / No API key found The key must go in the apikey header. Check the address matches your project ref.
Game can’t read or insert rows Row Level Security is on but has no policy allowing it. Add one, like “anyone can select”.
Project paused Free projects pause when idle. Click Restore in the dashboard.
Secret key ended up in the game code Rotate it now (Project Settings → API Keys), then remove it from the code and the history.

Checklist