Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,32 @@ You can use it in two ways:

## Installation

Install the SDK via npm:
**Inside Base44 apps**: The SDK is already available. No installation needed.

**External apps**: Install the SDK via npm:

```bash
npm install @base44/sdk
```

> **Note**: In Base44-generated apps, the SDK is already installed for you.

## Modules

The SDK provides access to Base44's functionality through the following modules:

- **[`agents`](https://docs.base44.com/developers/references/sdk/docs/interfaces/agents)**: Interact with AI agents and manage conversations.
- **[`analytics`](https://docs.base44.com/developers/references/sdk/docs/interfaces/analytics)**: Track custom events in your app.
- **[`app-logs`](https://docs.base44.com/developers/references/sdk/docs/interfaces/app-logs)**: Access and query app logs.
- **[`auth`](https://docs.base44.com/developers/references/sdk/docs/interfaces/auth)**: Manage user authentication, registration, and session handling.
- **[`connectors`](https://docs.base44.com/developers/references/sdk/docs/interfaces/connectors)**: Manage OAuth connections and access tokens for third-party services.
- **[`entities`](https://docs.base44.com/developers/references/sdk/docs/interfaces/entities)**: Work with your app's data entities using CRUD operations.
- **[`functions`](https://docs.base44.com/developers/references/sdk/docs/interfaces/functions)**: Execute backend functions.
- **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Pre-built integrations for external services.
- **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Access pre-built and third-party integrations.

## Quick starts
## Quickstarts

How you get started depends on your context:
How you get started depends on whether you're working inside a Base44-generated app or building your own.

### Inside a Base44 app
### Inside Base44 apps

In Base44-generated apps, the client is pre-configured. Just import and use it:

Expand All @@ -58,32 +59,32 @@ const tasks = await base44.entities.Task.list();

### External apps

When using Base44 as a backend for your own app, create and configure the client yourself:
When using Base44 as a backend for your own app, install the SDK and create the client yourself:

```typescript
import { createClient } from '@base44/sdk';
import { createClient } from "@base44/sdk";

// Create a client for your Base44 app
const base44 = createClient({
appId: 'your-app-id' // Find this in the Base44 editor URL
appId: "your-app-id", // Find this in the Base44 editor URL
});

// Read public data (anonymous access)
// Read public data
const products = await base44.entities.Products.list();

// Authenticate a user (token is automatically set)
await base44.auth.loginViaEmailPassword('user@example.com', 'password');
await base44.auth.loginViaEmailPassword("user@example.com", "password");

// Now operations use the authenticated user's permissions
// Access user's data
const userOrders = await base44.entities.Orders.list();
```

### Service role

For backend code that needs admin-level access, use the service role. Service role is only available in Base44-hosted backend functions:
By default, the client operates with user-level permissions, limiting access to what the current user can see and do. The service role provides elevated permissions for backend operations and is only available in Base44-hosted backend functions. External backends can't use service role permissions.

```typescript
import { createClientFromRequest } from 'npm:@base44/sdk';
import { createClientFromRequest } from "npm:@base44/sdk";

Deno.serve(async (req) => {
const base44 = createClientFromRequest(req);
Expand All @@ -97,7 +98,15 @@ Deno.serve(async (req) => {

## Learn more

For complete documentation, guides, and API reference, visit the **[Base44 SDK Documentation](https://docs.base44.com/developers/landing)**.
The best way to get started with the JavaScript SDK is to have Base44 build an app for you. Once you have an app, you can explore the generated code and experiment with the SDK to see how it works in practice. You can also ask Base44 to demonstrate specific features of the SDK.

For a deeper understanding, check out these guides:

1. [Base44 client](https://docs.base44.com/developers/references/sdk/getting-started/client) - Work with the client in frontend, backend, and external app contexts.
2. [Work with data](https://docs.base44.com/developers/references/sdk/getting-started/work-with-data) - Create, read, update, and delete data.
3. [Common SDK patterns](https://docs.base44.com/developers/references/sdk/getting-started/work-with-sdk) - Authentication, integrations, functions, and error handling.

For the complete documentation and API reference, visit the **[Base44 Developer Docs](https://docs.base44.com/developers/home)**.

## Development

Expand Down