Client Setup
How to create and configure the Base44 client.Contents
- In Base44-Generated Apps
- In External Apps
- In Backend Functions
- Authentication Modes (Anonymous, User, Service Role)
- Available Modules
- Client Methods
- Client Configuration Options
In Base44-Generated Apps
Inside a Base44 app, the client is automatically created and configured. Import it from@/api/base44Client and use it as base44:
In External Apps
When using Base44 as a backend from an external app, install the SDK and create a client by callingcreateClient() directly:
- ❌
createClient({ clientId: "..." })- WRONG parameter name - ❌
createClient({ id: "..." })- WRONG parameter name - ❌
createClient({ appId: "...", onError: ... })- WRONG: onError must be in options - ✅
createClient({ appId: "..." })- CORRECT parameter name - ✅
createClient({ appId: "...", options: { onError: ... } })- CORRECT: onError in options
In Backend Functions
createClientFromRequest() is designed for Base44-hosted backend functions. It extracts auth from request headers that Base44 injects and returns a client that includes service role access (base44.asServiceRole). For frontends and external backends, use createClient() instead.
Authentication Modes
Anonymous Mode
No authentication. Can only access public resources.User Mode
After user logs in, the client automatically includes their token.Service Role Mode
Admin-level access. Backend only.Available Modules
The client exposes these modules:Client Methods
The client provides these methods:setToken
Updates the authentication token for all subsequent API requests and WebSocket connections.cleanup
Disconnects WebSocket connections. Call when you’re done with the client or when the component unmounts.Client Configuration Options
- The parameter name is
appId, notclientIdorid. Using the wrong parameter name will cause errors. - The
onErrorhandler must be nested inside theoptionsobject, not at the top level.