Supabase Quickstart

supabase/supabase

A Clarity
5 Steps
8 min Time
macOS, Linux, Windows Tested On
100% Copy-Paste Ready
0 Issues

Get Supabase running and interact with your first database in under 8 minutes. This guide covers creating a project, installing the client library, and performing basic CRUD operations.

Prerequisites

  • 🌐
    Supabase Account Free account at supabase.com
  • 💻
    Node.js Version 18 or higher
  • 📦
    Package Manager npm, yarn, or pnpm

Create a Supabase Project

1

Create a Supabase Project

~2 min

Option A: Using the Dashboard (Recommended for beginners)

🌐 Create a new project at supabase.com/dashboard/new
  1. Click “New Project”
  2. Choose your organization
  3. Enter a project name and database password
  4. Select a region close to your users
  5. Click “Create new project”

💡 Save your database password securely - you'll need it for direct database connections.

Option B: Using the Supabase CLI

bash
# Install Supabase CLI
npm install -g supabase

Login to Supabase

supabase login

Create a new project (interactive)

supabase projects create my-project –org-id your-org-id

⚠️ Find your org-id in your Supabase dashboard URL: supabase.com/dashboard/org/[org-id]

Install Supabase Client

2

Install Supabase Client

~1 min

Install the Supabase JavaScript client library:

bash
npm install @supabase/supabase-js
Expected output:
added 1 package in 2s

Using other package managers:

bash
# Yarn
yarn add @supabase/supabase-js

pnpm

pnpm add @supabase/supabase-js

Initialize and Connect

3

Initialize and Connect

~1 min

Get your project credentials from the Supabase dashboard:

🔑 Find your API keys in Project Settings > API

Create a new file to initialize the Supabase client:

typescript
// supabase.ts
import { createClient } from '@supabase/supabase-js'

const supabaseUrl = ‘https://your-project-ref.supabase.co’ const supabaseAnonKey = ‘your-anon-key’

export const supabase = createClient(supabaseUrl, supabaseAnonKey)

⚠️ Never expose your service_role key in client-side code. Use the anon key for browser applications.

Test the connection:

typescript
// test-connection.ts
import { supabase } from './supabase'

async function testConnection() { const { data, error } = await supabase.from(’_test’).select(’*’).limit(1)

if (error && error.code === ‘42P01’) { console.log(‘Connected successfully! (Table does not exist yet)’) } else if (error) { console.error(‘Connection error:’, error.message) } else { console.log(‘Connected successfully!’) } }

testConnection()

🎉
Connected to Supabase!

Your client is now configured and ready to interact with your database.

Create a Table

4

Create a Table

~2 min

Option A: Using the Dashboard (Recommended)

  1. Go to the Table Editor in your Supabase dashboard
  2. Click “New Table”
  3. Create a todos table with these columns:
Name Type Default Primary
id int8 - Yes (auto)
title text - No
completed bool false No
created_at timestamptz now() No

Option B: Using SQL

Go to the SQL Editor and run:

sql
CREATE TABLE todos (
  id BIGSERIAL PRIMARY KEY,
  title TEXT NOT NULL,
  completed BOOLEAN DEFAULT FALSE,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

– Enable Row Level Security (recommended) ALTER TABLE todos ENABLE ROW LEVEL SECURITY;

– Create a policy to allow all operations (for testing) CREATE POLICY “Allow all operations” ON todos FOR ALL USING (true) WITH CHECK (true);

Expected output:
Success. No rows returned

💡 Row Level Security (RLS) is enabled by default on new tables. The policy above allows all operations for testing purposes.

Insert and Query Data

5

Insert and Query Data

~2 min

Insert data:

typescript
import { supabase } from './supabase'

// Insert a single row const { data, error } = await supabase .from(’todos’) .insert({ title: ‘Learn Supabase’ }) .select()

console.log(‘Inserted:’, data)

Expected output:
Inserted: [
  {
    id: 1,
    title: 'Learn Supabase',
    completed: false,
    created_at: '2026-02-03T10:30:00.000Z'
  }
]

Insert multiple rows:

typescript
const { data, error } = await supabase
  .from('todos')
  .insert([
    { title: 'Build an app' },
    { title: 'Deploy to production' }
  ])
  .select()

console.log(‘Inserted:’, data)

Query data:

typescript
// Fetch all todos
const { data: todos, error } = await supabase
  .from('todos')
  .select('*')
  .order('created_at', { ascending: false })

console.log(‘All todos:’, todos)

Expected output:
All todos: [
  { id: 3, title: 'Deploy to production', completed: false, ... },
  { id: 2, title: 'Build an app', completed: false, ... },
  { id: 1, title: 'Learn Supabase', completed: false, ... }
]

Update data:

typescript
const { data, error } = await supabase
  .from('todos')
  .update({ completed: true })
  .eq('id', 1)
  .select()

console.log(‘Updated:’, data)

Delete data:

typescript
const { error } = await supabase
  .from('todos')
  .delete()
  .eq('id', 1)

if (!error) console.log(‘Deleted successfully’)

🚀
You're now using Supabase!

You've created a table and performed full CRUD operations. Explore authentication, realtime subscriptions, and storage next.

Next Steps