Skip to main content

Database

NaijaBase gives every project a dedicated PostgreSQL 15 database hosted in Lagos, Nigeria.

Connection options

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:

TypeUse for
UUIDPrimary keys (gen_random_uuid())
TEXTStrings, names, descriptions
INTEGERPrices in kobo, counts
BOOLEANFlags
JSONBFlexible structured data
TIMESTAMPTZDates with timezone

Next steps