Client configuration
DB options
These options define your local cache.
schemais a hard coded schema for your local cachestoragedetermines the storage engines for your local cache (see Storage)
Sync options
These options define how you want to sync with the server.
serverUrlis the url of the server where your project lives e.g.https://<project-id>.triplit.ioautoConnectdetermines whether the client should connect to the server immediately upon instantiation. If set tofalse, you can manually connect with theclient.connect()method.
⚠️
The client connects over
WebSockets (opens in a new tab),
so you if you are instantiating a client in code that may run in an
environment where WebSockets are not available (e.g. the server during
server-side rendering), you should set autoConnect to false or preferably
to an environmental
variable (opens in a new tab) that
indicates whether the client should connect.
The serverUrl can be updated with the client.updateServerUrl method.
Auth options
These options define how you authenticate with your client database and remote database.
tokenis a jwt that is used to identify the user to the client database and remote databases (see the Auth guide).claimsPathis the path to the Triplit claims on the token. It should be a.separated string likepath.to.claims. This should match the value set on your project in the Triplit Dashboard.onSessionErroris a function that is called when the client receives an error from the server about the session, which will lead to the sync connection to being terminated. Read more about refreshing a session in the Sessions guide.refreshOptionscan be used to set therefreshHandlerandintervalfor the client. Read more about refreshing a session in the Sessions guide.
Experimental options
These options are experimental and may change in the future. All keys fall under the experimental key.
onDatabaseInitis a hook that runs after your client-side database has initialized and before any client operations are run and syncing begins. This hook provides a DB instance and aneventwhich tells you information about the database startup state.