The Basic SDK supports two database modes that determine how data is stored and synchronized. Choose the mode that best fits your application’s needs.Documentation Index
Fetch the complete documentation index at: https://docs.basic.tech/llms.txt
Use this file to discover all available pages before exploring further.
Overview
| Feature | Sync Mode (Default) | Remote Mode |
|---|---|---|
| Local Storage | IndexedDB | None |
| Offline Support | Yes | No |
| Real-time Updates | Yes (WebSocket) | No |
useQuery Auto-refresh | Yes | No |
| SSR Compatible | Partial | Yes |
| Authentication Required | For sync only | For all operations |
Sync Mode (Default)
Sync mode provides a local-first experience with automatic synchronization to the cloud.app/providers.tsx
How It Works
- Data is stored locally in IndexedDB
- Changes are immediately available locally (instant UI updates)
- A WebSocket connection syncs changes to/from the cloud
- Other devices and users receive updates in real-time
Benefits
- Works Offline: Users can read and write data without an internet connection. Changes sync when they reconnect.
- Instant UI: No loading spinners for data operations—changes appear immediately.
- Real-time Sync: All connected clients see changes instantly via WebSocket.
useQueryAuto-refresh: Components usinguseQueryautomatically re-render when data changes.
Considerations
- Requires IndexedDB (browser environment)
- Initial sync downloads all user data
- Not suitable for server-side rendering of user data
Example Usage
Remote Mode
Remote mode makes direct REST API calls to the server without local storage.app/providers.tsx
How It Works
- Every database operation makes an HTTP request to the Basic API
- No local caching or storage
- Data is fetched fresh on each request
Benefits
- No IndexedDB Dependencies: Works in environments where IndexedDB isn’t available
- SSR-Friendly: Better for server-side rendering patterns
- Simple Architecture: No sync complexity, just API calls
- Always Fresh: Data is always fetched from the server
Considerations
- Requires Internet: No offline support
- Requires Authentication: All operations (including reads) require the user to be signed in
- No Real-time Updates:
useQuerywon’t auto-update; you need to manually refetch - Network Latency: Each operation waits for the network round-trip
Example Usage
Error Handling in Remote Mode
Remote mode throwsNotAuthenticatedError when attempting write operations without being signed in:
Graceful Degradation for Reads
In remote mode, read operations gracefully handle unauthenticated state:| Operation | Unauthenticated Behavior |
|---|---|
getAll() | Returns empty array [] |
get(id) | Returns null |
filter() | Returns empty array [] |
add() | Throws NotAuthenticatedError |
put() | Throws NotAuthenticatedError |
update() | Throws NotAuthenticatedError |
delete() | Throws NotAuthenticatedError |
When to Use Each Mode
Use Sync Mode When:
- Building a PWA or offline-capable app
- You want real-time collaboration features
- Instant UI feedback is important
- Users work with moderate amounts of data
Use Remote Mode When:
- Building an SSR-heavy Next.js application
- IndexedDB isn’t available in your environment
- You don’t need offline support
- You want simple, stateless API calls
- Data is too large to sync locally
Checking Current Mode
You can check which mode is active usingdbMode from useBasic:

