Skip to content

WIP: Node.js Client SDK Tutorial #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

michaelbarnes
Copy link
Contributor

This PR introduces a "from scratch" node.js tutorial for developers. This is WIP and needs more polish.

@HeinrichvonStein
Copy link

mint.json should also be updated to reflect the new Client SDKs section

Screenshot 2025-03-24 at 07 41 32

## Introduction
In this tutorial, we’ll explore how to create a new Node.js applicaiton with TypeScript and PowerSync for offline-first capabilities. In the following sections, we’ll walk through the process of integrating PowerSync into a Node.js application, setting up local-first storage, and handling synchronization efficiently.

## Prerequisits

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a Warning note to make it stand out


## Setup

### Creating a new project

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This section could be merged into Project Setup

...
```

<Note>The PowerSync Node.js SDK requires `@powersync/better-sqlite3` to be installed</Note>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A link to thee PowerSync Node.js SDK would be helpful. Not sure if this is the right place for it though.


### Adding PowerSync

Create a `src` directory and add three files:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Create a `src` directory and add three files:
Create a `src` directory and add the following three files:

```

#### Connector.ts
This file will be the connector which will fetch a JWT used by PowerSync for authentication and another function which will handle uploads to the backend source database.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This file will be the connector which will fetch a JWT used by PowerSync for authentication and another function which will handle uploads to the backend source database.
This file will serve as the connector, responsible for retrieving a JWT for PowerSync authentication and providing a function to handle uploads to the backend source database.

```

#### index.ts
The main application file used in this guide to show you how to set up and initialize PowerSync.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The main application file used in this guide to show you how to set up and initialize PowerSync.
The main application file used in this guide which demonstrates how to set up and initialize PowerSync.

This will start the app, initialize the database and connect to the PowerSync instance.

<Warning>
Depending on what you set for `dbFilename`, the app start (and all is working correctly) three files will be created; `<dbFilename>.db`, `<dbFilename>.db-shm` and `<dbFilename>.db-wal`. You should exclude these from version control when creating the project so make sure to update your `.gitignore` accordingly.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little confusing

the app start (and all is working correctly) three files will be created;

## Introduction
In this tutorial, we’ll explore how to create a new Node.js applicaiton with TypeScript and PowerSync for offline-first capabilities. In the following sections, we’ll walk through the process of integrating PowerSync into a Node.js application, setting up local-first storage, and handling synchronization efficiently.

## Prerequisits

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Prerequisits
## Prerequisites

@rkistner rkistner changed the base branch from docs to main May 16, 2025 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants