Installation
Initialization
Basic Client
Initialize a client with your TrailBase server URL:Client with Existing Tokens
If you have persisted tokens from a previous session:Client from Cookies
For server-side rendering or when working with cookies:Auth State Changes
Listen to authentication state changes:Authentication
Login
Logout
Check Current User
Access Tokens
Refresh Token
Record API
List Records
Read a Single Record
Create a Record
Create Multiple Records
Update a Record
Delete a Record
Filtering
TrailBase supports powerful filtering with comparison operators:Available Comparison Operators
equal- Equality (default)notEqual- Not equallessThan- Less thanlessThanEqual- Less than or equalgreaterThan- Greater thangreaterThanEqual- Greater than or equallike- SQL LIKE pattern matchingregexp- Regular expression matching@within- Spatial within (for geospatial data)@intersects- Spatial intersects@contains- Spatial contains
Real-time Subscriptions
Subscribe to a Single Record
Subscribe to All Records
WebSocket Subscriptions
For improved performance, you can use WebSocket-based subscriptions:Batch Operations
Execute multiple operations in a single transaction:File Handling
Access File URLs
Avatar URL
Error Handling
Advanced Usage
Custom Fetch Options
Deferred Operations
Build operations without executing them immediately:Type Definitions
User
Tokens
ListResponse
Pagination
Best Practices
Always handle authentication errors gracefully and redirect users to login when tokens expire.
The client automatically refreshes auth tokens before they expire. Manual refresh is rarely needed.