Skip to content

Commit d14f9d9

Browse files
committed
Add back PWA support; fix readme.
1 parent ddf48a0 commit d14f9d9

File tree

6 files changed

+453
-53
lines changed

6 files changed

+453
-53
lines changed

demos/react-supabase-todolist/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ And then edit `.env.local` to insert your credentials for Supabase.
2929
Run the development server:
3030

3131
```bash
32-
pnpm watch
32+
pnpm dev
3333
```
3434

35-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
35+
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.
3636

3737
## Progressive Web App (PWA)
3838

39-
This demo is PWA compatible. PWA is not available in development (watch) mode.
39+
This demo is PWA compatible, and works fully offline. PWA is not available in development (watch) mode. The manifest and service worker is built using [vite-plugin-pwa](https://vite-pwa-org.netlify.app/).
4040

41-
Build the production codebase
41+
Build the production codebase:
4242

4343
```bash
4444
pnpm build
4545
```
4646

47-
Run the production server
47+
Run the production server:
4848

4949
```bash
50-
pnpm start
50+
pnpm preview
5151
```
5252

5353
Open a browser on the served URL and install the PWA.

demos/react-supabase-todolist/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"babel-loader": "^9.1.3",
3232
"typescript": "^5",
3333
"vite": "^5.1.4",
34+
"vite-plugin-pwa": "^0.19.2",
3435
"vite-plugin-top-level-await": "^1.4.1",
3536
"vite-plugin-wasm": "^3.3.0"
3637
}

demos/react-supabase-todolist/public/manifest.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

demos/react-supabase-todolist/src/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<html lang="en">
22
<head>
3-
<link rel="manifest" href="/manifest.json" />
43
<meta name="theme-color" content="#c44eff" />
54
<link rel="apple-touch-icon" href="/icons/icon.png" />
65
<link rel="stylesheet" href="./app/globals.css" />

demos/react-supabase-todolist/vite.config.mts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { fileURLToPath, URL } from 'url';
44

55
import { defineConfig } from 'vite';
66
import react from '@vitejs/plugin-react';
7+
import { VitePWA } from 'vite-plugin-pwa';
78

89
// https://vitejs.dev/config/
910
export default defineConfig({
@@ -26,7 +27,46 @@ export default defineConfig({
2627
exclude: ['@journeyapps/wa-sqlite', '@journeyapps/powersync-sdk-web'],
2728
include: ['object-hash', 'uuid', 'event-iterator', 'js-logger', 'lodash', 'can-ndjson-stream']
2829
},
29-
plugins: [wasm(), topLevelAwait(), react()],
30+
plugins: [
31+
wasm(),
32+
topLevelAwait(),
33+
react(),
34+
VitePWA({
35+
registerType: 'autoUpdate',
36+
includeAssets: ['powersync-logo.svg', 'supabase-logo.png', 'favicon.ico'],
37+
manifest: {
38+
theme_color: '#c44eff',
39+
background_color: '#c44eff',
40+
display: 'standalone',
41+
scope: '/',
42+
start_url: '/',
43+
name: 'PowerSync NextJS Demo',
44+
short_name: 'PowerSync NextJS',
45+
icons: [
46+
{
47+
src: '/icons/icon-192x192.png',
48+
sizes: '192x192',
49+
type: 'image/png'
50+
},
51+
{
52+
src: '/icons/icon-256x256.png',
53+
sizes: '256x256',
54+
type: 'image/png'
55+
},
56+
{
57+
src: '/icons/icon-384x384.png',
58+
sizes: '384x384',
59+
type: 'image/png'
60+
},
61+
{
62+
src: '/icons/icon-512x512.png',
63+
sizes: '512x512',
64+
type: 'image/png'
65+
}
66+
]
67+
}
68+
})
69+
],
3070
worker: {
3171
format: 'es',
3272
plugins: () => [wasm(), topLevelAwait()]

0 commit comments

Comments
 (0)