Skip to content
Back to skills

nano-supabase

ASecurity

Skill for working with the nano-supabase codebase: a lightweight TypeScript library that emulates Supabase entirely in-browser/edge using PGlite (Postgres via WASM). Covers architecture, fetch adapter routing, auth/storage/data flows, PostgREST WASM parser, connection pooling, cross-runtime compatibility, build system, and testing conventions. Use when implementing features, fixing bugs, writing tests, or reviewing code in this project.

  • 8 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added May 27, 2026
databasestypescriptbashsqlnodetestinggitapibackend

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 19 files and shows the line behind each finding

Scanned May 27, 2026

npx -y skills add filipecabaco/nano-supabase --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of nano-supabase?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for nano-supabase
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/filipecabaco-nano-supabase/badge)](https://www.skillsdirectory.com/skills/filipecabaco-nano-supabase)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nano-supabase
description: >
  Skill for working with the nano-supabase codebase: a lightweight TypeScript library that emulates
  Supabase entirely in-browser/edge using PGlite (Postgres via WASM). Covers architecture, fetch
  adapter routing, auth/storage/data flows, PostgREST WASM parser, connection pooling, cross-runtime
  compatibility, build system, and testing conventions. Use when implementing features, fixing bugs,
  writing tests, or reviewing code in this project.
---

# nano-supabase

Lightweight Supabase emulation running entirely in-browser/edge. Zero network calls. Full auth (JWT + RLS), storage (pluggable backends), PostgREST query parsing (WASM), priority-queue connection pooling over PGlite.

## Architecture

```
@supabase/supabase-js
  -> Fetch Adapter (routes by URL path)
     /auth/v1/*    -> AuthHandler (signup, signin, signout, refresh)
     /rest/v1/*    -> PostgREST Parser (WASM) -> SQL
     /storage/v1/* -> StorageHandler (buckets, objects, signed URLs)
  -> Priority Queue (CRITICAL / HIGH / MEDIUM / LOW)
  -> Connection Pooler (N-to-1 multiplexing)
  -> PGlite (PostgreSQL in WebAssembly)
```

## Project Layout

```
src/
  index.ts              # Public exports
  client.ts             # createLocalSupabaseClient, createFetchAdapter
  supabase-client.ts    # Supabase-compatible client wrapper
  postgrest-parser.ts   # PostgREST -> SQL (WASM binding)
  pooler.ts             # N-to-1 connection pooler
  queue.ts              # Priority queue (4 levels)
  types.ts              # QueryPriority, QueryResult, PoolerConfig
  auth/                 # JWT via Web Crypto, sessions, refresh tokens
    handler.ts          # signUp, signIn, signOut, refreshToken
    crypto.ts           # Web Crypto API helpers
    jwt.ts              # signJWT, verifyJWT, decodeJWT
    schema.ts           # Auth SQL schema (CREATE IF NOT EXISTS)
    types.ts            # User, Session, AuthResponse
  storage/              # Storage API emulation
    handler.ts          # Bucket/object CRUD
    backend.ts          # StorageBackend interface + MemoryStorageBackend
    schema.ts           # Storage SQL schema
  fetch-adapter/        # Intercepts supabase-js fetch calls
    index.ts            # createLocalFetch: URL routing
    auth-routes.ts      # /auth/v1/* dispatch
    data-routes.ts      # /rest/v1/* dispatch
    storage-routes.ts   # /storage/v1/* dispatch
    auth-context.ts     # JWT claims extraction for RLS
    error-handler.ts    # Error -> Response conversion
tests/
  compat.ts             # Deno/Bun test shim (runtime-agnostic)
  *.test.ts             # Split by concern: auth, data, storage, fetch-adapter, applications, full-user-flow
```

## Key Technical Details

- **TypeScript strict mode**, ESNext modules, ES2022 target
- **Cross-runtime**: Node.js, Deno, Bun, Browser, Cloudflare Workers. Use Web Crypto API only (no Node crypto)
- **PGlite is a peer dependency** - users provide their own instance
- **postgrest-parser** bundled as WASM in dist/
- **esbuild** bundles to dist/index.js (~21KB) + WASM (~377KB)
- **SQL schemas** use `CREATE IF NOT EXISTS` for idempotent initialization
- **RLS functions**: `auth.uid()`, `auth.role()`, `auth.email()` backed by PostgreSQL roles (`anon`, `authenticated`, `service_role`)

## Common Patterns

Create a client:
```typescript
const client = createLocalSupabaseClient(db);
// or manually:
const client = createClient(url, key, { global: { fetch: createLocalFetch(db, key) } });
```

Auth flow:
```typescript
await supabase.auth.signUp({ email, password });
const { data: { session } } = await supabase.auth.signInWithPassword({ email, password });
// JWT now in session, RLS active
```

Data with RLS:
```typescript
// Create table + RLS policy, then query as authenticated user
const { data } = await supabase.from('todos').select('*');
// Only returns rows matching RLS policy
```

Storage:
```typescript
await supabase.storage.from('avatars').upload('path/file.png', blob);
const { data } = await supabase.storage.from('avatars').download('path/file.png');
const { data: { signedUrl } } = await supabase.storage.from('avatars').createSignedUrl('path/file.png', 3600);
```

## Testing

- **Behavior over implementation**: Test real user workflows, not internals
- **No helper files**: Inline all setup for full context at each test
- **No excessive mocking**: Use real PGlite instances
- **Each test** creates its own PGlite instance + client (isolated)
- **Full workflows**: signup -> insert -> query -> verify RLS -> cleanup
- Runtime-agnostic via `compat.ts` shim

Run tests:
```bash
deno test --allow-read --allow-env tests/
bun test tests/
```

## Build

```bash
npm run build          # esbuild -> dist/
npm run build:dev      # tsc only
npm run build:types    # declarations
```

CI: GitHub Actions matrix (Bun + Deno), tests split by concern.

## Rules

- No comments in code
- No helper/utility files
- No Node.js-specific APIs
- Test behavior, not implementation
- Do not test what the compiler verifies

Files in this skill

  • .dockerignore61 B
  • .fly/fly.toml725 B
  • .npmignore14 B
  • AGENTS.md23.9 KB
  • BENCHMARKS.md4.7 KB
  • CLAUDE.md5.3 KB
  • Dockerfile733 B
  • SKILL.md4.9 KB
  • benchmarks/.gitignore19 B
  • benchmarks/20260329T182549Z.json943 B
  • benchmarks/20260329T182645Z.json941 B
  • biome.json644 B
  • bun.lock41.8 KB
  • deno.lock3.5 KB
  • dist/base-RR3DHML3.js12.5 KB
  • dist/base-RR3DHML3.js.map69.7 KB
  • dist/chunk-LGVFXVVX.js16.4 KB
  • dist/chunk-LGVFXVVX.js.map65.7 KB
  • dist/chunk-OOYSG7AB.js68.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.