Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
title: "Next.js + PowerSync"
description: "A guide for creating a new Next.js application with PowerSync for offline/local first functionality"
keywords: ["next.js", "web"]
title: "Next.js"
description: "A guide for creating a new Next.js application with PowerSync for offline/local first functionality."
---

## Introduction
In this tutorial, we’ll explore how to enhance a Next.js application with offline-first capabilities using PowerSync. In the following sections, we’ll walk through the process of integrating PowerSync into a Next.js application, setting up local-first storage, and handling synchronization efficiently.
In this guide, we'll explore how to enhance a Next.js application with offline-first capabilities using PowerSync. We'll walk through the process of integrating PowerSync into a Next.js application, setting up local-first storage, and handling synchronization efficiently.

<Note>At present PowerSync will not work with SSR enabled with Next.js and in this guide we disable SSR across the entire app. However, it is possible to have other pages, which do not require authentication for example, to still be rendered server-side. This can be done by only using the DynamicSystemProvider (covered further down in the guide) for specific pages. This means you can still have full SSR on other page which do not require PowerSync.</Note>
<Note>At present PowerSync will not work with SSR enabled with Next.js and in this guide we disable SSR across the entire app. However, it is possible to have other pages, which do not require authentication for example, to still be rendered server-side. This can be done by only using the DynamicSystemProvider (covered further down in the guide) for specific pages. This means you can still have full SSR on other pages which do not require PowerSync.</Note>

## Setup

Expand Down Expand Up @@ -41,7 +39,7 @@ Would you like to customize the import alias (`@/*` by default)? Yes
```

<Warning>
Do not use Turbopack when setting up a new Next.js project as well be updating the `next.config.ts` to use Webpack. This is done because we need to enable:
Do not use Turbopack when setting up a new Next.js project as we'll be updating the `next.config.ts` to use Webpack. This is done because we need to enable:
1. asyncWebAssembly
2. topLevelWait
</Warning>
Expand Down
114 changes: 60 additions & 54 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@
"usage/use-case-examples/prioritized-sync",
"usage/use-case-examples/query-json-in-sqlite",
"usage/use-case-examples/raw-tables",
"usage/use-case-examples/sequential-id-mapping",
"usage/use-case-examples/cascading-deletes",
"usage/use-case-examples/aws-s3-storage",
"usage/use-case-examples/pdf-attachments",
"usage/use-case-examples/custom-write-checkpoints"
]
},
Expand Down Expand Up @@ -222,7 +226,8 @@
"integration-guides/supabase-+-powersync/handling-attachments",
"integration-guides/supabase-+-powersync/realtime-streaming",
"integration-guides/supabase-+-powersync/rls-and-sync-rules",
"integration-guides/supabase-+-powersync/local-development"
"integration-guides/supabase-+-powersync/local-development",
"integration-guides/supabase-+-powersync/connector-performance"
]
},
{
Expand Down Expand Up @@ -310,6 +315,7 @@
]
},
"client-sdk-references/javascript-web/javascript-spa-frameworks",
"client-sdk-references/javascript-web/nextjs",
"client-sdk-references/javascript-web/usage-examples",
"client-sdk-references/javascript-web/encryption",
"client-sdk-references/javascript-web/api-reference"
Expand Down Expand Up @@ -400,6 +406,7 @@
]
},
"self-hosting/enterprise",
"self-hosting/generate-dev-token",
{
"group": "Appendix",
"pages": [
Expand All @@ -411,59 +418,6 @@
}
]
},
{
"tab": "Tutorials",
"groups": [
{
"group": " ",
"pages": [
"tutorials/overview"
]
},
{
"group": "Client",
"pages": [
"tutorials/client/overview",
{
"group": "Client SDKs",
"pages": [
"tutorials/client/sdks/web/next-js"
]
},
{
"group": "Attachments / Files",
"pages": [
"tutorials/client/attachments-and-files/overview",
"tutorials/client/attachments-and-files/aws-s3-storage-adapter",
"tutorials/client/attachments-and-files/pdf-attachment"
]
},
{
"group": "Performance",
"pages": [
"tutorials/client/performance/overview",
"tutorials/client/performance/supabase-connector-performance"
]
},
{
"group": "Data Management",
"pages": [
"tutorials/client/data/overview",
"tutorials/client/data/cascading-delete",
"tutorials/client/data/sequential-id-mapping"
]
}
]
},
{
"group": "Self-Hosting",
"pages": [
"tutorials/self-host/overview",
"tutorials/self-host/generate-dev-token"
]
}
]
},
{
"tab": "Resources",
"groups": [
Expand Down Expand Up @@ -700,6 +654,58 @@
{
"source": "/client-sdk-references/kotlin-multiplatform/libraries/room",
"destination": "/client-sdk-references/kotlin/libraries/room"
},
{
"source": "/tutorials/client/data/cascading-delete",
"destination": "/usage/use-case-examples/cascading-deletes"
},
{
"source": "/tutorials/client/data/sequential-id-mapping",
"destination": "/usage/use-case-examples/sequential-id-mapping"
},
{
"source": "/tutorials/overview",
"destination": "/usage/use-case-examples"
},
{
"source": "/tutorials/client/overview",
"destination": "/usage/use-case-examples"
},
{
"source": "/tutorials/client/sdks/web/next-js",
"destination": "/client-sdk-references/javascript-web/nextjs"
},
{
"source": "/tutorials/client/attachments-and-files/overview",
"destination": "/usage/use-case-examples/attachments-files"
},
{
"source": "/tutorials/client/attachments-and-files/aws-s3-storage-adapter",
"destination": "/usage/use-case-examples/aws-s3-storage"
},
{
"source": "/tutorials/client/attachments-and-files/pdf-attachment",
"destination": "/usage/use-case-examples/pdf-attachments"
},
{
"source": "/tutorials/client/performance/overview",
"destination": "/integration-guides/supabase-+-powersync/connector-performance"
},
{
"source": "/tutorials/client/performance/supabase-connector-performance",
"destination": "/integration-guides/supabase-+-powersync/connector-performance"
},
{
"source": "/tutorials/self-host/overview",
"destination": "/self-hosting/getting-started"
},
{
"source": "/tutorials/self-host/generate-dev-token",
"destination": "/self-hosting/generate-dev-token"
},
{
"source": "/tutorials/client/data/overview",
"destination": "/usage/use-case-examples"
}
],
"appearance": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
---
title: "Improve Supabase Connector"
description: "In this tutorial we will show you how to improve the performance of the Supabase Connector for the [React Native To-Do List demo app](https://github.com/powersync-ja/powersync-js/tree/main/demos/react-native-supabase-todolist)."
title: "Connector Performance"
description: "Learn how to improve the performance of the Supabase Connector using batching strategies."
---

# Background

The demos in the [powersync-js](https://github.com/powersync-ja/powersync-js/tree/main/demos) monorepo provide a minimal working example that illustrate the use of PowerSync with different frameworks.
The demos are therefore not necessarily optimized for performance and can therefore be improved.
The demos are therefore not necessarily optimized for performance and can be improved.

This tutorial demonstrates how to improve the Supabase Connector's performance by implementing two batching strategies that reduce the number of database operations.
This guide demonstrates how to improve the Supabase Connector's performance by implementing two batching strategies that reduce the number of database operations.

# Batching Strategies
## Batching Strategies

The two batching strategies that will be implemented are:
The two batching strategies are:

1. Sequential Merge Strategy, and
2. Pre-sorted Batch Strategy
2. Pre-sorted Batch Strategy

<AccordionGroup>
<Accordion title="Sequential Merge Strategy">
Expand Down Expand Up @@ -121,7 +119,7 @@ The two batching strategies that will be implemented are:
- `putOps`: For `PUT` operations, organized by table name
- `deleteOps`: For `DELETE` operations, organized by table name
- `patchOps`: For `PATCH` operations (partial updates)

- Loop through all operations, sort them into the three collections, and then process all operations in batches.

```typescript {8-11, 17-20, 23, 26-29, 32-53, 56, 72}
Expand Down Expand Up @@ -209,7 +207,7 @@ The two batching strategies that will be implemented are:
</Accordion>
</AccordionGroup>

# Differences
## Differences

<AccordionGroup>
<Accordion title="Operation grouping strategy">
Expand Down Expand Up @@ -264,14 +262,14 @@ The two batching strategies that will be implemented are:
</Card>
</CardGroup>

# Use cases
## Use cases

<CardGroup cols={2}>
<Card title="Sequential Merge Strategy">
You need more granular control over batch sizes

You want more detailed operation logging

You need to handle mixed operation types more efficiently
<br />
**Best for**: Mixed operation types
Expand All @@ -282,7 +280,7 @@ The two batching strategies that will be implemented are:
</Card>
<Card title="Pre-sorted Batch Strategy">
You have a large number of similar operations.

You want to minimize the number of network requests.
<br />
<br />
Expand All @@ -292,4 +290,4 @@ The two batching strategies that will be implemented are:
<br />
**Trade-off**: Higher memory usage
</Card>
</CardGroup>
</CardGroup>
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
---
title: "Generate a Development Token"
description: "In this tutorial we will show you how to generate a development token for the self-hosted [PowerSync Service](https://powersync.mintlify.app/architecture/powersync-service#powersync-service)."
description: "Learn how to generate a development token for the self-hosted PowerSync Service."
---

# Introduction

Development tokens are useful for:
- getting started quickly without implementing full auth config
- sanity checking your sync rules config (were they applied correctly)
- temporarily impersonating a specific user to debug specific issues
- Getting started quickly without implementing full auth config
- Sanity checking your sync rules config (were they applied correctly)
- Temporarily impersonating a specific user to debug specific issues

# Use Case
## Use Case

Development tokens can be used either with the
- [test-client](https://github.com/powersync-ja/powersync-service/tree/main/test-client), or
- [Sync Diagnostics Client](/resources/troubleshooting#sync-diagnostics-client)

# Generate a Development Token
## Generate a Development Token
Development tokens can be generated via either
- [PowerSync Cloud](/installation/authentication-setup/development-tokens/#PowerSync-Cloud-Dashboard), or
- locally with a self-hosted setup (described in this tutorial)
- Locally with a self-hosted setup (described below)

<Steps>
<Step title={"Generate a SharedSecret"}>
Expand Down Expand Up @@ -72,4 +70,3 @@ Development tokens can be generated via either
</Frame>
</Step>
</Steps>

9 changes: 0 additions & 9 deletions tutorials/client/attachments-and-files/overview.mdx

This file was deleted.

9 changes: 0 additions & 9 deletions tutorials/client/data/overview.mdx

This file was deleted.

11 changes: 0 additions & 11 deletions tutorials/client/overview.mdx

This file was deleted.

8 changes: 0 additions & 8 deletions tutorials/client/performance/overview.mdx

This file was deleted.

8 changes: 0 additions & 8 deletions tutorials/client/sdks/overview.mdx

This file was deleted.

43 changes: 0 additions & 43 deletions tutorials/overview.mdx

This file was deleted.

Loading