Meta tags:
description= Lightweight WASM Postgres;
Headings (most frequently used words):
pglite, install, and, start, in, getting, started, with, about, docs, extensions, reference, node, bun, deno, the, browser, making, query, using, parameterised, queries, what, next, framework, hooks, tools,
Text of the page (most frequently used words):
pglite (37), the (18), and (15), task (11), electric (10), query (9), with (9), sql (9), todo (8), #install (8), into (7), using (7), done (7), npm (7), insert (7), can (6), database (6), const (6), values (6), from (6), page (5), extensions (5), there (5), for (5), queries (5), update (5), true (5), bash (5), api (4), that (4), browser (4), postgres (4), support (4), your (4), method (4), exec (4), new (4), deno (4), bun (4), supports (3), repl (3), bundler (3), are (3), framework (3), about (3), await (3), ret (3), use (3), create (3), table (3), import (3), getting (3), started (3), next (2), videos (2), you (2), test (2), examples (2), both (2), list (2), supported (2), orms (2), builders (2), debugging (2), development (2), component (2), has (2), provide (2), multiple (2), multi (2), tab (2), worker (2), working (2), react (2), vue (2), hooks (2), when (2), live (2), extension (2), methods (2), main (2), querying (2), what (2), parameterized (2), where (2), this (2), false (2), let (2), some (2), data (2), pgdata (2), persist (2), memory (2), cdn (2), package (2), start (2), path (2), add (2), yarn (2), pnpm (2), node (2), sync (2), docs (2), navigation (2), dual, licensed, under, postgresql, license, apache, previous, pager, have, open, out, plugins, via, its, maintain, easily, embedded, web, app, aid, part, application, itself, only, single, exclusive, connection, enable, sharing, instance, between, tabs, help, configuring, see, make, within, much, easier, less, boilerplate, number, built, persistence, virtual, file, systems, also, enables, reactive, underlying, changes, learn, more, along, other, options, available, read, documentation, transactions, set, user, supplied, always, best, these, parameterised, output, rows, log, console, select, now, retrieve, item, perfect, migrations, batch, inserts, raw, load, boolean, default, text, serial, primary, key, not, exists, first, two, former, parameters, while, latter, statements, making, idb, indexeddb, then, https, jsdelivr, net, dist, index, such, jsdeliver, installed, imported, usual, manager, native, filesystem, project, used, any, javascript, benchmarks, reference, catalog, upgrade, locale, prepopulated, pgdump, tools, socket, filesystems, sidebar, return, top, menu, github, home, search, skip, content,
Text of the page (random words):
getting started with pglite pglite skip to content search k main navigation home about docs repl electric github npm menu return to top sidebar navigation about what is pglite videos docs getting started pglite api live queries filesystems framework hooks react vue bundler support multi tab worker repl component orms query builders sync using postgres sync pglite socket pglite tools package pgdump prepopulated fs locale support upgrade path extensions extensions catalog extension development reference examples benchmarks debugging on this page getting started with pglite pglite can be used in both node bun deno or the browser and with any javascript framework install and start in node bun deno install into your project npm pnpm yarn bun deno bash npm install electric sql pglite bash pnpm install electric sql pglite bash yarn add electric sql pglite bash bun install electric sql pglite bash deno add npm electric sql pglite to use the in memory postgres js import pglite from electric sql pglite const db new pglite or to persist to the native filesystem js const db new pglite path to pgdata install and start in the browser it can be installed and imported using your usual package manager js import pglite from electric sql pglite or using a cdn such as jsdeliver js import pglite from https cdn jsdelivr net npm electric sql pglite dist index js then for an in memory postgres js const db new pglite or to persist the database to indexeddb js const db new pglite idb my pgdata making a query there are two methods for querying the database query and exec the former supports parameters while the latter supports multiple statements first let s create a table and insert some test data using the exec method js await db exec create table if not exists todo id serial primary key task text done boolean default false insert into todo task done values install pglite from npm true insert into todo task done values load pglite true insert into todo task done values create a table true insert into todo task done values insert some data true insert into todo task values update a task the exec method is perfect for migrations and batch inserts with raw sql now let s retrieve an item using query method js const ret await db query select from todo where id 1 console log ret rows output js id 1 task install pglite from npm done false using parameterised queries when working with user supplied values it s always best to use parameterized queries these are supported on the query method we can use this to update a task js const ret await db query update todo set task 2 done 3 where id 1 5 update a task using parameterized queries true what next to learn more about querying and transactions along with the other methods and options available you can read the main pglite api documentation there is also a live query extension that enables reactive queries to update a ui when the underlying database changes pglite has a number of built in virtual file systems to provide persistence for your database there are framework hooks to make working with pglite within react and vue much easier with less boilerplate for help configuring pglite with your bundler see the bundler support page as pglite only has a single exclusive connection to the database we provide a multi tab worker to enable sharing a pglite instance between multiple browser tabs there is a repl component that can be easily embedded into a web app to aid in debugging and development or as part of a database application itself we maintain a list of orms and query builders that support pglite pglite supports both postgres extensions and pglite plugins via its extensions api and there is a list of supported extensions we have a page of examples that you can open to test out pglite in the browser pager previous page videos next page pglite api dual licensed under apache 2 0 and the postgresql license electric
|