> pglite
You are an expert in PGlite, the lightweight WASM Postgres build that runs in the browser, Node.js, and Deno. You help developers embed a full Postgres instance (with extensions like pgvector, PostGIS) in client-side apps, Electron, React Native, and serverless functions — providing real SQL with JSONB, full-text search, and vector similarity search at ~3MB compressed, without a server.
curl "https://skillshub.wtf/TerminalSkills/skills/pglite?format=md"PGlite — Postgres in the Browser
You are an expert in PGlite, the lightweight WASM Postgres build that runs in the browser, Node.js, and Deno. You help developers embed a full Postgres instance (with extensions like pgvector, PostGIS) in client-side apps, Electron, React Native, and serverless functions — providing real SQL with JSONB, full-text search, and vector similarity search at ~3MB compressed, without a server.
Core Capabilities
Browser Usage
import { PGlite } from "@electric-sql/pglite";
import { vector } from "@electric-sql/pglite/vector";
// Create in-memory database
const db = new PGlite({
extensions: { vector },
});
// Or persist to IndexedDB
const db = new PGlite({
dataDir: "idb://my-app-db",
extensions: { vector },
});
// Full Postgres SQL
await db.exec(`
CREATE TABLE IF NOT EXISTS documents (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
content TEXT,
embedding vector(384),
metadata JSONB DEFAULT '{}',
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX ON documents USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);
CREATE INDEX ON documents USING GIN (metadata);
CREATE INDEX ON documents USING GIN (to_tsvector('english', title || ' ' || content));
`);
// Insert
await db.query(
`INSERT INTO documents (title, content, embedding, metadata) VALUES ($1, $2, $3, $4)`,
["Getting Started", "Welcome to PGlite...", embedding, JSON.stringify({ category: "tutorial" })],
);
// Full-text search
const results = await db.query(`
SELECT title, ts_rank(to_tsvector('english', content), query) AS rank
FROM documents, plainto_tsquery('english', $1) query
WHERE to_tsvector('english', content) @@ query
ORDER BY rank DESC LIMIT 10
`, ["postgres wasm"]);
// Vector similarity search
const similar = await db.query(`
SELECT title, 1 - (embedding <=> $1::vector) AS similarity
FROM documents
ORDER BY embedding <=> $1::vector
LIMIT 5
`, [queryEmbedding]);
// JSONB queries
const tutorials = await db.query(`
SELECT * FROM documents WHERE metadata->>'category' = $1
`, ["tutorial"]);
Live Queries (Reactive)
import { live } from "@electric-sql/pglite/live";
const db = new PGlite({ extensions: { live } });
// Subscribe to query results — re-runs when data changes
const unsubscribe = await db.live.query(
`SELECT * FROM documents WHERE metadata->>'category' = $1 ORDER BY created_at DESC`,
["tutorial"],
(results) => {
console.log("Documents updated:", results.rows);
// Re-renders your UI automatically
},
);
// React hook
import { useLiveQuery } from "@electric-sql/pglite-react";
function DocumentList({ category }: { category: string }) {
const docs = useLiveQuery(
`SELECT * FROM documents WHERE metadata->>'category' = $1`,
[category],
);
return <ul>{docs?.rows.map(d => <li key={d.id}>{d.title}</li>)}</ul>;
}
Installation
npm install @electric-sql/pglite
Best Practices
- Full Postgres — Not a subset; real Postgres with JSONB, CTEs, window functions, extensions
- IndexedDB persistence — Use
idb://prefix for data directory; survives page refreshes - pgvector — Vector search in the browser; run RAG locally without a server
- Live queries — Subscribe to query results; automatic re-execution when underlying data changes
- 3MB compressed — Small enough for browser apps; loads in <1 second
- Drizzle/Prisma — Use with Drizzle ORM for type-safe queries; PGlite driver available
- Testing — Use PGlite in tests instead of Docker Postgres; instant setup, zero cleanup
- Local-first — Pair with Electric SQL for sync; local PGlite + cloud Postgres
> related_skills --same-repo
> zustand
You are an expert in Zustand, the small, fast, and scalable state management library for React. You help developers manage global state without boilerplate using Zustand's hook-based stores, selectors for performance, middleware (persist, devtools, immer), computed values, and async actions — replacing Redux complexity with a simple, un-opinionated API in under 1KB.
> zod
You are an expert in Zod, the TypeScript-first schema declaration and validation library. You help developers define schemas that validate data at runtime AND infer TypeScript types at compile time — eliminating the need to write types and validators separately. Used for API input validation, form validation, environment variables, config files, and any data boundary.
> xero-accounting
Integrate with the Xero accounting API to sync invoices, expenses, bank transactions, and contacts — and generate financial reports like P&L and balance sheet. Use when: connecting apps to Xero, automating bookkeeping workflows, syncing accounting data, or pulling financial reports programmatically.
> windsurf-rules
Configure Windsurf AI coding assistant with .windsurfrules and workspace rules. Use when: customizing Windsurf for a project, setting AI coding standards, creating team-shared Windsurf configurations, or tuning Cascade AI behavior.