Skip to main content

createClient(config): Base44Client
Creates a Base44 client. This is the main entry point for the Base44 SDK. It creates a client that provides access to the SDK’s modules, such as entities, auth, and functions. How you get a client depends on your context:
  • Inside a Base44 app: The client is automatically created and configured for you. Import it from @/api/base44Client.
  • External app using Base44 as a backend: Call createClient() directly in your code to create and configure the client.
The client supports three authentication modes:
  • Anonymous: Access modules without authentication using base44.moduleName. Operations are scoped to public data and permissions.
  • User authentication: Access modules with user-level permissions using base44.moduleName. Operations are scoped to the authenticated user’s data and permissions. Use base44.auth.loginViaEmailPassword() or other auth methods to get a token.
  • Service role authentication: Access modules with elevated permissions using base44.asServiceRole.moduleName. Operations bypass entity access rules and field-level security, giving full read and write access to all of the app’s data. Only available in Base44-hosted backend functions. Create a client with service role authentication using createClientFromRequest().
For example, when using the entities module:
  • Anonymous: Can only read public data.
  • User authentication: Can access the current user’s data.
  • Service role authentication: Can read and write any record, bypassing access rules.
Most modules are available in all three modes, but with different permission levels. However, some modules are only available in specific authentication modes.

Parameters

CreateClientConfig
requerido
Configuration object for the client.
string
The Base44 server URL.You don’t need to set this for production use. The SDK defaults to https://base44.app.Set this when using a local development server to point SDK requests at your local machine instead of the hosted backend.
string
requerido
The Base44 app ID.You can find the appId in the browser URL when you’re in the app editor. It’s the string between /apps/ and /editor/.
string
User authentication token. Used to authenticate as a specific user.Inside Base44 apps, the token is managed automatically. For external apps, use auth methods like loginViaEmailPassword() which set the token automatically.
CreateClientOptions
Additional client options.
(error: Error) => void
Optional error handler that will be called whenever an API error occurs.

Returns

Base44Client The Base44 client instance. Provides access to all SDK modules for interacting with the app. A configured Base44 client instance with access to all SDK modules.
AgentsModule
requerido
Agents module for managing AI agent conversations.
AiGatewayModule
requerido
AI Gateway module for connecting to the Base44 AI Gateway with your own SDK.
AnalyticsModule
requerido
Analytics module for tracking custom events in your app.
AppLogsModule
requerido
App logs module for tracking app usage.
AuthModule
requerido
Auth module for user authentication and management.
UserConnectorsModule
requerido
Connectors module for app-user OAuth flows.
EntitiesModule
requerido
Entities module for CRUD operations on your data models.
FunctionsModule
requerido
Functions module for invoking custom backend functions.
IntegrationsModule
requerido
Integrations module for calling pre-built integration endpoints.
() => void
requerido
Cleanup function to disconnect WebSocket connections. Call when you’re done with the client.
object
requerido
Provides access to supported modules with elevated permissions.Service role authentication provides elevated permissions for backend operations. Unlike user authentication, which is scoped to a specific user’s permissions, service role authentication bypasses entity access rules and field-level security entirely, giving full read and write access to all of the app’s data.
AgentsModule
requerido
Agents module with elevated permissions.
AiGatewayModule
requerido
AI Gateway module with the service-role token.
AppLogsModule
requerido
App logs module with elevated permissions.
ConnectorsModule
requerido
Connectors module for OAuth token retrieval.
EntitiesModule
requerido
Entities module with elevated permissions.
FunctionsModule
requerido
Functions module with elevated permissions.
IntegrationsModule
requerido
Integrations module with elevated permissions.
SsoModule
requerido
SSO module for generating SSO tokens.
() => void
requerido
Cleanup function to disconnect WebSocket connections.

Example