Skip to content

Commit 952bc28

Browse files
committed
chore: update bare example to use hard-coded access token
1 parent 0201703 commit 952bc28

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

examples/sync-demo-bare/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ Before running the example, you need to set up a SQLite Cloud database:
4141

4242
5. **Get your credentials**
4343
- Navigate to your database's **Configuration** tab
44-
- Copy your **Database ID** and **API Key**
44+
- Copy your **Database ID**
45+
- Generate or copy an **Access Token** for the user/session you want to test with
4546

4647
### 2. Set Up React Native Environment
4748

@@ -56,16 +57,16 @@ Follow the [React Native environment setup guide](https://reactnative.dev/docs/s
5657
cp .env.example .env
5758
```
5859

59-
2. **Fill in your credentials** in the `.env` file:
60+
2. **Fill in your configuration** in the `.env` file:
6061

6162
```env
6263
SQLITE_CLOUD_DATABASE_ID=db_xxxxxxxxxxxxxxxxxxxxxxxx
63-
SQLITE_CLOUD_API_KEY=your-api-key-here
6464
DATABASE_NAME=sync-demo.db
6565
TABLE_NAME=test_table
6666
```
6767

6868
**Note**: The `TABLE_NAME` must match the table name you created in SQLite Cloud and enabled for OffSync.
69+
3. **Hardcode your access token** in [`src/App.tsx`](/Users/damlayildiz/SqliteCloud/sqlite-sync-react-native/examples/sync-demo-bare/src/App.tsx) by replacing the `HARDCODED_ACCESS_TOKEN` placeholder.
6970

7071
### 4. Install Dependencies
7172

examples/sync-demo-bare/src/App.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ import {
1818
useSyncStatus,
1919
useSqliteTransaction,
2020
} from '@sqliteai/sqlite-sync-react-native';
21-
import {
22-
SQLITE_CLOUD_DATABASE_ID,
23-
SQLITE_CLOUD_API_KEY,
24-
DATABASE_NAME,
25-
TABLE_NAME,
26-
} from '@env';
21+
import { SQLITE_CLOUD_DATABASE_ID, DATABASE_NAME, TABLE_NAME } from '@env';
22+
23+
let HARDCODED_ACCESS_TOKEN: string;
24+
HARDCODED_ACCESS_TOKEN = 'replace-with-access-token';
2725

2826
/**
2927
* Demo app showcasing the reactive hooks and dual connection architecture:
@@ -278,12 +276,7 @@ function TestApp() {
278276
}
279277

280278
export default function App() {
281-
if (
282-
!SQLITE_CLOUD_DATABASE_ID ||
283-
!SQLITE_CLOUD_API_KEY ||
284-
!DATABASE_NAME ||
285-
!TABLE_NAME
286-
) {
279+
if (!SQLITE_CLOUD_DATABASE_ID || !DATABASE_NAME || !TABLE_NAME) {
287280
return (
288281
<View style={styles.container}>
289282
<Text style={styles.error}>
@@ -297,6 +290,20 @@ export default function App() {
297290
);
298291
}
299292

293+
if (HARDCODED_ACCESS_TOKEN === 'replace-with-access-token') {
294+
return (
295+
<View style={styles.container}>
296+
<Text style={styles.error}>
297+
Replace the hardcoded access token in src/App.tsx before running the
298+
example.
299+
</Text>
300+
<Text style={styles.errorDetails}>
301+
See README.md for setup instructions.
302+
</Text>
303+
</View>
304+
);
305+
}
306+
300307
return (
301308
<SQLiteSyncProvider
302309
databaseId={SQLITE_CLOUD_DATABASE_ID}
@@ -315,7 +322,7 @@ export default function App() {
315322
]}
316323
syncMode="polling"
317324
adaptivePolling={{ baseInterval: 3000 }}
318-
apiKey={SQLITE_CLOUD_API_KEY}
325+
accessToken={HARDCODED_ACCESS_TOKEN}
319326
debug={true}
320327
>
321328
<TestApp />
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
declare module '@env' {
22
export const SQLITE_CLOUD_DATABASE_ID: string;
3-
export const SQLITE_CLOUD_API_KEY: string;
43
export const DATABASE_NAME: string;
54
export const TABLE_NAME: string;
65
}

0 commit comments

Comments
 (0)