Guides

How to set up a database for your app — step by step, no server of your own

Illustration: steps from an empty project to a table with its first row

It sounds like sysadmin territory: "set up a database." In reality a beginner doesn't install or run anything — cloud services hand you a ready database in a couple of clicks. Let's walk the whole path on Supabase: from sign-up to your first saved row. By the end you'll have a real database you can connect an app to.

Why Supabase: a free tier with no card, a friendly visual table editor, and plain SQL under the hood. But the logic is the same everywhere — on Firebase or Neon the steps look similar.

1. Create a project

Go to supabase.com, sign in with GitHub, hit New project. It asks three things:

  • Name — anything, e.g. my-first-app.
  • Database password — make it strong and save it to a password manager right away. You'll need it later and it isn't shown twice.
  • Region — pick the one closest to your users; it's faster.

Hit Create and wait a minute or two — the service spins up the database for you.

2. Create a table

A database is a set of tables, and a table is like an Excel sheet: rows and columns. In the left menu open Table EditorNew table. Name it in the plural, e.g. notes.

Leave Enable Row Level Security (RLS) checked — it's the protection that, without it, lets anyone reach your data. For now just don't uncheck it; you'll come back to access rules later.

3. Add columns

Columns are the fields you want to store. Supabase already creates two system ones: id (a unique row number) and created_at (when it was made). Add your own via Add column. For a notes table, say:

  • title — type text (the note's heading).
  • body — type text (the text).
  • done — type bool (a "done" checkbox), default false.

Type matters: text for strings, int8 for numbers, bool for yes/no, timestamptz for dates. Save the table.

4. Insert the first row by hand

Before wiring up code, check it's alive. In Table Editor hit Insert row, fill in title and body, save. The row shows up in the table — the database works. That's your first saved data, which will outlive a restart of anything.

5. Grab the connection keys

For an app to reach the database it needs two values. Open Project SettingsAPI:

  • Project URL — your database's address.
  • anon public key — the public key for connecting from an app.

Copy both. And an important rule right away: these can't go straight into the code — put them in environment variables, in a .env file:

SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=eyJ...

6. Connect from the app

Now the app can read and write. With the official library it's a couple of lines — here's a query that reads all notes:

import { createClient } from '@supabase/supabase-js'
const db = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY)

const { data } = await db.from('notes').select('*')

Under the hood this becomes the SQL query SELECT * FROM notes, but you don't have to write it by hand — the library does it for you.

What's next

The most important open item is setting up those access rules (RLS) so each user sees only their own rows. That's a topic of its own, but it's what turns a "practice" database into a safe one. For now you have a working database, a table, and a connection — the foundation of any data-driven app.

Question: is the free tier really enough?

For a learning project and your first users — with room to spare. Supabase's free tier gives you a full database, and you'll only hit the limits once real traffic shows up. By then you'll understand what you're paying for.

Question: should I pick a SQL or NoSQL database?

For a first project a table-based SQL database, like in this walkthrough, is almost always simpler: the data is visible, the relations are clear. If you're curious about the difference and when you'd want the other, see SQL vs NoSQL.

Learn vibe coding — don’t just read about it

Short story-lessons, an agent simulator and daily practice — in our mobile app. Free.

Open the app
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →