Client configuration
DB options
These options define your local cache.
schema
is a hard coded schema for your local cachestorage
determines the storage engines for your local cache (see Storage)
Sync options
These options define how you want to sync with the server.
serverUrl
is the url of the server where your project lives e.g.https://<project-id>.triplit.io
autoConnect
determines 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.
token
is a jwt that is used to identify the user to the client database and remote databases (see the Auth guide). Providing atoken
will set the variable$session.SESSION_USER_ID
on the database, which is used for authorization rules.claimsPath
is 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.
The TriplitClient
's session API provides methods to switch out the token and update the client's connection to the server. For best practices on using these APIs and updating user sessions, see the Auth guide.