Skip to content

Examples

We have a number of examples showing how to use PGlite along with its capabilities:

  • Basic
    A basic example showing how to initiate a PGlite database and perform queries using .exec()

  • Query Params
    Aa example showing how to perform parametrised queries using .query() method.

  • Copy
    An example showing to use the COPY command with the PGlite /dev/blob device.

  • Dump Data Dir
    Example of the db.dumpDataDir() method to save a tarball of a database.

  • Live Query
    Reactivity example using the live query extensions .live.query() method.

  • Live Changes
    Reactivity example using the live query extensions .live.changes() method.

  • Live Incremental Query
    Reactivity example using the live query extensions .live.incrementalQuery() method.

  • Notify and Listen
    Example showing the use of the NOTIFY and LISTEN Postgres commands via the PGlite .listen() API.

  • OPFS VFS
    An example demonstrating the OPFS Access Handle Pool VFS.

  • PL/PGSQL
    Demonstration of PGlite's support for Postgres's built-in SQL procedural language extension "PL/PGSQL".

  • Extension: pgvector
    An example showing how to use pgvector with PGlite.

  • Multi Tab Worker
    Demonstration of the multi tab worker, enabling multiple browser tabs to share a PGlite database.