Skip to content

Commit 2f1059b

Browse files
authored
Merge branch 'main' into docs/custom-api-integrations
2 parents dec05b2 + ac0b300 commit 2f1059b

17 files changed

+493
-55
lines changed

README.md

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
# Base44 JavaScript SDK
22

3-
The Base44 SDK provides a JavaScript interface for building apps on the Base44 platform. When Base44 generates your app, the generated code uses the SDK to authenticate users, manage your app's data, interact with AI agents, and more. You can then use the same SDK to modify and extend your app.
3+
The Base44 SDK provides a JavaScript interface for building apps on the Base44 platform.
4+
5+
You can use it in two ways:
6+
7+
- **Inside Base44 apps**: When Base44 generates your app, the SDK is already set up and ready to use.
8+
- **External apps**: Use the SDK to build your own frontend or backend that uses Base44 as a backend service.
9+
10+
## Installation
11+
12+
Install the SDK via npm:
13+
14+
```bash
15+
npm install @base44/sdk
16+
```
17+
18+
> **Note**: In Base44-generated apps, the SDK is already installed for you.
419
520
## Modules
621

@@ -12,11 +27,15 @@ The SDK provides access to Base44's functionality through the following modules:
1227
- **[`connectors`](https://docs.base44.com/sdk-docs/interfaces/connectors)**: Manage OAuth connections and access tokens for third-party services.
1328
- **[`entities`](https://docs.base44.com/sdk-docs/interfaces/entities)**: Work with your app's data entities using CRUD operations.
1429
- **[`functions`](https://docs.base44.com/sdk-docs/interfaces/functions)**: Execute backend functions.
15-
- **[`integrations`](https://docs.base44.com/sdk-docs/type-aliases/integrations)**: Pre-built server-side functions for external services.
30+
- **[`integrations`](https://docs.base44.com/sdk-docs/type-aliases/integrations)**: Pre-built integrations for external services.
1631

17-
## Example
32+
## Quick starts
1833

19-
Here's a quick look at working with data in the SDK, using the `entities` module to create, update, and list records. In this example, we're working with a custom `Task` entity:
34+
How you get started depends on your context:
35+
36+
### Inside a Base44 app
37+
38+
In Base44-generated apps, the client is pre-configured. Just import and use it:
2039

2140
```typescript
2241
import { base44 } from "@/api/base44Client";
@@ -37,6 +56,45 @@ await base44.entities.Task.update(newTask.id, {
3756
const tasks = await base44.entities.Task.list();
3857
```
3958

59+
### External apps
60+
61+
When using Base44 as a backend for your own app, create and configure the client yourself:
62+
63+
```typescript
64+
import { createClient } from '@base44/sdk';
65+
66+
// Create a client for your Base44 app
67+
const base44 = createClient({
68+
appId: 'your-app-id' // Find this in the Base44 editor URL
69+
});
70+
71+
// Read public data (anonymous access)
72+
const products = await base44.entities.Products.list();
73+
74+
// Authenticate a user (token is automatically set)
75+
await base44.auth.loginViaEmailPassword('user@example.com', 'password');
76+
77+
// Now operations use the authenticated user's permissions
78+
const userOrders = await base44.entities.Orders.list();
79+
```
80+
81+
### Service role
82+
83+
For backend code that needs admin-level access, use the service role. Service role is only available in Base44-hosted backend functions:
84+
85+
```typescript
86+
import { createClientFromRequest } from 'npm:@base44/sdk';
87+
88+
Deno.serve(async (req) => {
89+
const base44 = createClientFromRequest(req);
90+
91+
// Access all data with admin-level permissions
92+
const allOrders = await base44.asServiceRole.entities.Orders.list();
93+
94+
return Response.json({ orders: allOrders });
95+
});
96+
```
97+
4098
## Learn more
4199

42100
For complete documentation, guides, and API reference, visit the **[Base44 SDK Documentation](https://docs.base44.com/sdk-getting-started/overview)**.
@@ -45,13 +103,17 @@ For complete documentation, guides, and API reference, visit the **[Base44 SDK D
45103

46104
### Build the SDK
47105

106+
Build the SDK from source:
107+
48108
```bash
49109
npm install
50110
npm run build
51111
```
52112

53113
### Run tests
54114

115+
Run the test suite:
116+
55117
```bash
56118
# Run all tests
57119
npm test
@@ -64,6 +126,7 @@ npm run test:coverage
64126
```
65127

66128
For E2E tests, create a `tests/.env` file with:
129+
67130
```
68131
BASE44_APP_ID=your_app_id
69132
BASE44_AUTH_TOKEN=your_auth_token

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@base44/sdk",
3-
"version": "0.8.17",
3+
"version": "0.8.18",
44
"description": "JavaScript SDK for Base44 API",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -19,7 +19,9 @@
1919
"docs": "typedoc",
2020
"prepublishOnly": "npm run build",
2121
"create-docs": "npm run create-docs:generate && npm run create-docs:process",
22+
"create-docs-local": "npm run create-docs && npm run copy-docs-local",
2223
"push-docs": "node scripts/mintlify-post-processing/push-to-docs-repo.js",
24+
"copy-docs-local": "node scripts/mintlify-post-processing/copy-to-local-docs.js",
2325
"create-docs:generate": "typedoc",
2426
"create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
2527
},

0 commit comments

Comments
 (0)