Skip to content

Commit d31d9f9

Browse files
committed
Improve minimal example projects readmes
1 parent 3c11c38 commit d31d9f9

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

demos/example-nextjs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This example is built using [Next.js](https://nextjs.org/) and the [PowerSync JS
44

55
To see it in action:
66

7-
1. Make sure to run `pnpm build:packages` in the root directory of this Git repo.
7+
1. Make sure to run `pnpm install` and `pnpm build:packages` in the root directory of this repo.
88
2. Copy `.env.local.template` to `.env.local`, and complete the environment variables. You can generate a [temporary development token](https://docs.powersync.com/usage/installation/authentication-setup/development-tokens), or leave blank to test with local-only data.
9-
3. `pnpm start`
10-
4. Open the localhost URL in the browser displayed in the terminal output.
9+
3. cd into this directory and run `pnpm start`.
10+
4. Open the localhost URL displayed in the terminal output in your browser.

demos/example-vite/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# PowerSync Vite bundling test
22

3+
This is a minimal example demonstrating bundling with Vite. It attempts a connection to verify that web workers load correctly, but networks requests will fail since no credentials are configured. See [src/index.js](src/index.js) for details.
4+
35
To see it in action:
46

5-
1. Make sure to run `pnpm build:packages` in the root directory of this Git repo.
6-
2. `pnpm start`
7-
3. Open the localhost URL in the browser displayed in the terminal output.
7+
1. Make sure to run `pnpm install` and `pnpm build:packages` in the root directory of this repo.
8+
2. cd into this directory, and run `pnpm start`.
9+
3. Open the localhost URL displayed in the terminal output in your browser.

demos/example-vite/src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,5 @@ const openDatabase = async () => {
6161
};
6262

6363
document.addEventListener('DOMContentLoaded', (event) => {
64-
console.log('hello');
6564
openDatabase();
6665
});

demos/example-webpack/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# PowerSync Webpack bundling test
22

3+
This is a minimal example demonstrating bundling with Webpack. It attempts a connection to verify that web workers load correctly, but networks requests will fail since no credentials are configured. See [src/index.js](src/index.js) for details.
4+
35
To see it in action:
46

5-
1. Make sure to run `pnpm build:packages` in the root directory of this Git repo.
6-
2. `pnpm start`
7-
3. Open the localhost URL in the browser displayed in the terminal output.
7+
1. Make sure to run `pnpm install` and `pnpm build:packages` in the root directory of this repo.
8+
2. cd into this directory, and run `pnpm start`.
9+
3. Open the localhost URL displayed in the terminal output in your browser.

demos/example-webpack/src/index.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ import {
66
Table
77
} from '@journeyapps/powersync-sdk-web';
88

9+
/**
10+
* A placeholder connector which doesn't do anything.
11+
* This is just used to verify that the sync workers can be loaded
12+
* when connecting.
13+
*/
14+
class DummyConnector {
15+
async fetchCredentials() {
16+
return {
17+
endpoint: '',
18+
token: ''
19+
};
20+
}
21+
22+
async uploadData(database) {}
23+
}
24+
925
export const AppSchema = new Schema([
1026
new Table({ name: 'customers', columns: [new Column({ name: 'name', type: ColumnType.TEXT })] })
1127
]);
@@ -15,7 +31,11 @@ let PowerSync;
1531
const openDatabase = async () => {
1632
PowerSync = new WASQLitePowerSyncDatabaseOpenFactory({
1733
schema: AppSchema,
18-
dbFilename: 'test.sqlite'
34+
dbFilename: 'test.sqlite',
35+
flags: {
36+
// This is disabled once CSR+SSR functionality is verified to be working correctly
37+
disableSSRWarning: true
38+
}
1939
}).getInstance();
2040

2141
await PowerSync.init();
@@ -25,8 +45,21 @@ const openDatabase = async () => {
2545

2646
const result = await PowerSync.getAll('SELECT * FROM customers');
2747
console.log('contents of customers: ', result);
48+
49+
console.log(
50+
`Attempting to connect in order to verify web workers are correctly loaded.
51+
This doesn't use any actual network credentials.
52+
Network errors will be shown: these can be ignored.`
53+
);
54+
55+
/**
56+
* Try and connect, this will setup shared sync workers
57+
* This will fail due to not having a valid endpoint,
58+
* but it will try - which is all that matters.
59+
*/
60+
await PowerSync.connect(new DummyConnector());
2861
};
2962

3063
document.addEventListener('DOMContentLoaded', (event) => {
3164
openDatabase();
32-
});
65+
});

0 commit comments

Comments
 (0)