Database
NaijaBase gives every project a dedicated PostgreSQL 15 database hosted in Lagos, Nigeria.
Connection options
Via the SDK (recommended)
import { createClient } from '@naijabase/js'
const naijabase = createClient(PROJECT_URL, ANON_KEY)
const { data, error } = await naijabase
.from('table_name')
.select('*')
Via direct connection string
Find your connection string on the project Dashboard tab:
postgresql://postgres:[PASSWORD]@db.[PROJECT_ID].naijabase.dev:5432/postgres
Use this with any PostgreSQL client:
- pgAdmin — GUI for Windows/Mac
- TablePlus — lightweight and fast
- psql — command line
- Prisma / Drizzle — ORM connection string
Creating tables
Use your PostgreSQL client or the dashboard to create tables:
CREATE TABLE products (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
price INTEGER NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);
Data types
NaijaBase supports all PostgreSQL data types. Commonly used:
| Type | Use for |
|---|---|
UUID | Primary keys (gen_random_uuid()) |
TEXT | Strings, names, descriptions |
INTEGER | Prices in kobo, counts |
BOOLEAN | Flags |
JSONB | Flexible structured data |
TIMESTAMPTZ | Dates with timezone |
Next steps
- Querying Data — select, insert, update, delete
- Row Level Security — control who sees what