This demonstrates a small Node.js CLI client opening a database, connecting PowerSync and running live queries.
This demo is configured to talk to an example backend you can host yourself. To get started:
- Start one of the Node.js backend examples from the self-host-demo repository.
- If necessary, change
.env
to point to the started backend and sync service. - Run
pnpm install
andpnpm build:packages
in the root of this repo. - In this directory, run
pnpm run start
.
This opens the local database, connects to PowerSync, waits for a first sync and then runs a simple query. Results from the query are printed every time it changes. Try:
- Updating a row in the backend database and see changes reflected in the running client.
- Enter
add('my list')
and see the new list show up in the backend database.
For more details, see the documentation for the PowerSync node package and check other examples:
- example-electron-node: An Electron example that runs PowerSync in the main process using the Node.js SDK.