Skip to main content
This page is part of an AI coding agent skill and is written for agents, not humans. For the human-readable Base44 docs, see the developer documentation.

Client Setup

How to create and configure the Base44 client.

Contents

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 calling createClient() directly:
Common Mistakes:
  • 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

⚠️ Critical:
  • The parameter name is appId, not clientId or id. Using the wrong parameter name will cause errors.
  • The onError handler must be nested inside the options object, not at the top level.

Type Definitions

CreateClientConfig

Base44Client