npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@naijabase/js

v0.1.1

Published

JavaScript SDK for NaijaBase — Nigerian backend platform

Readme

@naijabase/js

Official JavaScript/TypeScript SDK for NaijaBase — the Nigerian backend platform.

Install

npm install @naijabase/js

Quick Start

import { createClient } from '@naijabase/js'

const naijabase = createClient(
  'https://YOUR_PROJECT_ID.naijabase.dev',
  'nb_live_YOUR_API_KEY'
)

// Query your database
const { data, error } = await naijabase
  .from('users')
  .select('*')

console.log(data)

Database

Select

// All rows
const { data, error } = await naijabase.from('orders').select('*')

// Specific columns
const { data } = await naijabase.from('orders').select('id, name, amount')

// With filters
const { data } = await naijabase
  .from('orders')
  .select('*')
  .eq('status', 'pending')
  .gte('amount', 1000)
  .order('created_at', { ascending: false })
  .limit(10)

// Single row
const { data } = await naijabase.from('users').select('*').eq('id', '123').single()

Filter operators

| Method | SQL equivalent | |--------|----------------| | .eq('col', val) | col = val | | .neq('col', val) | col != val | | .gt('col', val) | col > val | | .lt('col', val) | col < val | | .gte('col', val) | col >= val | | .lte('col', val) | col <= val | | .like('col', '%pat%') | col LIKE '%pat%' | | .ilike('col', '%pat%') | col ILIKE '%pat%' | | .in('col', [1,2,3]) | col IN (1,2,3) | | .is('col', null) | col IS NULL |

Insert

// Single row
const { data, error } = await naijabase
  .from('users')
  .insert({ name: 'Chidi', email: '[email protected]' })

// Multiple rows
const { data, error } = await naijabase
  .from('products')
  .insert([
    { name: 'Jollof Rice', price: 1500 },
    { name: 'Egusi Soup', price: 2000 },
  ])

Update

const { data, error } = await naijabase
  .from('orders')
  .update({ status: 'shipped' })
  .eq('id', 'order-uuid-123')

Delete

const { error } = await naijabase
  .from('users')
  .delete()
  .eq('id', 'user-uuid-456')

Auth

// Sign up
const { user, session, error } = await naijabase.auth.signUp({
  email: '[email protected]',
  password: 'Password123!',
  name: 'Amaka Dev',         // optional
  company: 'Startup NG',    // optional
})

// Sign in
const { user, session, error } = await naijabase.auth.signIn({
  email: '[email protected]',
  password: 'Password123!',
})

// Get current user (from session — no network call)
const user = naijabase.auth.user()

// Get session
const session = naijabase.auth.session()

// Fetch user from API
const { data: user, error } = await naijabase.auth.getUser()

// Update profile
const { data, error } = await naijabase.auth.updateUser({ name: 'New Name' })

// Sign out
await naijabase.auth.signOut()

Storage

// Upload
const { data, error } = await naijabase
  .storage
  .from('avatars')
  .upload('user123/photo.jpg', file, { contentType: 'image/jpeg', upsert: true })

// Get public URL (no network call)
const { publicUrl } = naijabase
  .storage
  .from('avatars')
  .getPublicUrl('user123/photo.jpg')

// Download
const { data: blob, error } = await naijabase
  .storage
  .from('avatars')
  .download('user123/photo.jpg')

// List files
const { data: files, error } = await naijabase
  .storage
  .from('avatars')
  .list('user123/', { limit: 50, sortBy: { column: 'name', order: 'asc' } })

// Delete
const { error } = await naijabase
  .storage
  .from('avatars')
  .remove(['user123/photo.jpg', 'user123/old.png'])

Error Handling

Every method returns { data, error }. Errors are never thrown.

const { data, error } = await naijabase.from('orders').select('*')

if (error) {
  console.error(error.message)   // human-readable
  console.error(error.status)    // HTTP status code
  console.error(error.code)      // NaijaBase error code
} else {
  console.log(data)
}

TypeScript

The SDK is written in TypeScript with full type exports.

import { createClient, NaijaBaseResponse, User } from '@naijabase/js'

const naijabase = createClient(url, key)

interface Order {
  id: string
  amount: number
  status: 'pending' | 'shipped' | 'delivered'
}

const { data, error }: NaijaBaseResponse<Order[]> = await naijabase
  .from<Order>('orders')
  .select('*')
  .eq('status', 'pending')

Works With

  • React
  • Next.js
  • Vue.js
  • React Native
  • Node.js (18+)
  • Any JavaScript framework

License

MIT © NaijaBase