pglite
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "pglite" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-66cdf658424c820561164b8c2ba4f2aed76a399d32307962ed8116ef957329af. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
PGlite: a lightweight WASM build of Postgres that runs in browsers, Node.js, and Deno. Enables embedding a full Postgres instance in client apps, Electron, React Native, and serverless functions (supports extensions like pgvector and PostGIS), offering SQL features such as JSONB, full‑text search, and vector similarity search. Compressed size around 3MB and runs without a server.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: pglite
description: >-
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.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: Backend Development
tags:
- postgres
- wasm
- browser
- embedded
- local-first
- database
- lightweightPGlite — 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
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供浏览器端完整 Postgres 功能,支持 JSONB、全文搜索、向量相似性搜索等高价值能力
- 适用于客户端嵌入数据库、本地优先应用、无服务器函数等高频刚需场景
- 集成 pgvector、PostGIS 等扩展,满足 AI 应用和地理数据处理需求
Highlights
- description 精准描述 Skill 为 PGlite 专家,涵盖核心能力与使用场景
- 触发词边界清晰,不易与其他数据库工具混淆
Highlights
- 文档结构清晰,分 Core Capabilities、Installation、Best Practices
- 提供完整端到端代码示例,涵盖浏览器使用、实时查询、React 集成
- frontmatter 完整,单文件未超限,排版规范
Highlights
- 代码示例参数正确,涵盖主要异常处理(如 IndexedDB 持久化、扩展加载)
- 工具来源明确(@electric-sql/pglite),无不可逆操作
- 提供最佳实践指导,提升执行成功率
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 125
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.