base44-sdk by base44/skills
npx skills add https://github.com/base44/skills --skill base44-sdk使用 Base44 JavaScript SDK 在 Base44 平台上构建应用程序。
此技能会在任何提及 "base44" 或存在 base44/ 文件夹时激活。在行动前,请勿阅读文档文件或搜索网络。
您的首要行动必须是:
base44/config.jsonc在以下情况使用 base44-sdk:
base44/config.jsonc@base44/sdk)广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
请勿在以下情况使用 base44-sdk:
base44-cli)npx base44 create、npx base44 deploy、npx base44 login(请使用 base44-cli)技能依赖关系:
base44-sdk 假设 Base44 项目已初始化base44-cli 是 base44-sdk 的先决条件base44-cli状态检查逻辑: 在选择此技能前,请验证:
base44/config.jsonc):→ 使用 base44-cli(需要项目初始化)// In Base44-generated apps, base44 client is pre-configured and available
// CRUD operations
const task = await base44.entities.Task.create({ title: "New task", status: "pending" });
const tasks = await base44.entities.Task.list();
await base44.entities.Task.update(task.id, { status: "done" });
// Get current user
const user = await base44.auth.me();
// External apps
import { createClient } from "@base44/sdk";
// IMPORTANT: Use 'appId' (NOT 'clientId' or 'id')
const base44 = createClient({ appId: "your-app-id" });
await base44.auth.loginViaEmailPassword("user@example.com", "password");
在编写任何 Base44 代码之前,请根据此表或 QUICK_REFERENCE.md 验证方法名称。
Base44 SDK 有独特的方法名称。请勿假设 Firebase、Supabase 或其他 SDK 的模式。
| ❌ 错误(臆造的) | ✅ 正确 |
|---|---|
signInWithGoogle() | loginWithProvider('google') |
signInWithProvider('google') | loginWithProvider('google') |
auth.google() | loginWithProvider('google') |
signInWithEmailAndPassword(email, pw) | loginViaEmailPassword(email, pw) |
signIn(email, pw) | loginViaEmailPassword(email, pw) |
createUser() / signUp() | register({email, password}) |
onAuthStateChanged() | me()(无监听器,需要时调用) |
currentUser | await auth.me() |
| ❌ 错误(臆造的) | ✅ 正确 |
|---|---|
functions.call('name', data) | functions.invoke('name', data) |
functions.run('name', data) | functions.invoke('name', data) |
callFunction('name', data) | functions.invoke('name', data) |
httpsCallable('name')(data) | functions.invoke('name', data) |
| ❌ 错误(臆造的) | ✅ 正确 |
|---|---|
ai.generate(prompt) | integrations.Core.InvokeLLM({prompt}) |
openai.chat(prompt) | integrations.Core.InvokeLLM({prompt}) |
llm(prompt) | integrations.Core.InvokeLLM({prompt}) |
sendEmail(to, subject, body) | integrations.Core.SendEmail({to, subject, body}) |
email.send() | integrations.Core.SendEmail({to, subject, body}) |
uploadFile(file) | integrations.Core.UploadFile({file}) |
storage.upload(file) | integrations.Core.UploadFile({file}) |
| ❌ 错误(臆造的) | ✅ 正确 |
|---|---|
entities.Task.find({...}) | entities.Task.filter({...}) |
entities.Task.findOne(id) | entities.Task.get(id) |
entities.Task.insert(data) | entities.Task.create(data) |
entities.Task.remove(id) | entities.Task.delete(id) |
entities.Task.onChange(cb) | entities.Task.subscribe(cb) |
| 模块 | 用途 | 参考 |
|---|---|---|
entities | 数据模型的 CRUD 操作 | entities.md |
auth | 登录、注册、用户管理 | auth.md |
agents | AI 对话和消息 | base44-agents.md |
functions | 后端函数调用 | functions.md |
integrations | AI、电子邮件、文件上传、自定义 API | integrations.md |
connectors | OAuth 令牌(仅服务角色) | connectors.md |
analytics | 跟踪自定义事件和用户活动 | analytics.md |
appLogs | 在应用中记录用户活动 | app-logs.md |
users | 邀请用户加入应用 | users.md |
关于客户端设置和身份验证模式,请参阅 client.md。
每个参考文件都包含一个 "Type Definitions" 部分,其中包含模块方法、参数和返回值的 TypeScript 接口和类型。
获取类型化的实体、函数和代理: Base44 CLI 从您的项目资源(实体、函数、代理)生成类型,包括对 EntityTypeRegistry、FunctionNameRegistry 和 AgentNameRegistry 的增强,并将其连接到您的项目中,以便您无需手动设置即可获得自动完成和类型检查。关于如何生成类型,请使用 base44-cli 技能。
手动增强: 您也可以自己在 .d.ts 文件中增强注册表;请参阅 entities.md、functions.md 和 base44-agents.md 中的 Type Definitions 部分。
安装 Base44 SDK:
npm install @base44/sdk
重要: 切勿假设或硬编码 @base44/sdk 包的版本。请始终在不指定版本的情况下安装以获取最新版本。
在外部应用中创建客户端时,请始终使用 appId 作为参数名:
import { createClient } from "@base44/sdk";
// ✅ 正确
const base44 = createClient({ appId: "your-app-id" });
// ❌ 错误 - 请勿使用这些:
// const base44 = createClient({ clientId: "your-app-id" }); // 错误
// const base44 = createClient({ id: "your-app-id" }); // 错误
必需参数: appId (字符串) - 您的 Base44 应用 ID
可选参数:
token (字符串) - 预认证的用户令牌options (对象) - 配置选项
options.onError (函数) - 全局错误处理程序带错误处理程序的示例:
const base44 = createClient({
appId: "your-app-id",
options: {
onError: (error) => {
console.error("Base44 error:", error);
}
}
});
处理应用数据?
entitiesentities.importEntities()entities.EntityName.subscribe()用户管理?
authauth.me()auth.updateMe()users.inviteUser()AI 功能?
agents(需要已登录用户)agents.createConversation()agents.getConversations()integrations.Core.InvokeLLM()integrations.Core.GenerateImage()自定义后端逻辑?
functions.invoke()base44.asServiceRole.functions.invoke()外部服务?
integrations.Core.SendEmail()integrations.Core.UploadFile()integrations.custom.call()connectors(仅限后端)跟踪和分析?
analytics.track()appLogs.logUserInApp()const pendingTasks = await base44.entities.Task.filter(
{ status: "pending", assignedTo: userId }, // 查询
"-created_date", // 排序(降序)
10, // 限制
0 // 跳过
);
const user = await base44.auth.me();
if (!user) {
// 导航到您的自定义登录页面
navigate('/login', { state: { returnTo: window.location.pathname } });
return;
}
// 前端
const result = await base44.functions.invoke("processOrder", {
orderId: "123",
action: "ship"
});
// 后端函数 (Deno)
import { createClientFromRequest } from "npm:@base44/sdk";
Deno.serve(async (req) => {
const base44 = createClientFromRequest(req);
const { orderId, action } = await req.json();
// 使用服务角色进行处理以获取管理员访问权限
const order = await base44.asServiceRole.entities.Orders.get(orderId);
return Response.json({ success: true });
});
在后端函数中使用 asServiceRole 进行管理员级别的操作:
// 用户模式 - 遵循权限
const myTasks = await base44.entities.Task.list();
// 服务角色 - 完全访问权限(仅限后端)
const allTasks = await base44.asServiceRole.entities.Task.list();
const token = await base44.asServiceRole.connectors.getAccessToken("slack");
| 功能 | 前端 | 后端 |
|---|---|---|
entities(用户的数据) | 是 | 是 |
auth | 是 | 是 |
agents | 是 | 是 |
functions.invoke() | 是 | 是 |
integrations | 是 | 是 |
analytics | 是 | 是 |
appLogs | 是 | 是 |
users | 是 | 是 |
asServiceRole.* | 否 | 是 |
connectors | 否 | 是 |
后端函数使用 Deno.serve() 和 createClientFromRequest(req) 来获取经过适当身份验证的客户端。
每周安装量
726
仓库
GitHub 星标数
64
首次出现
2026年1月20日
安全审计
安装于
cursor637
claude-code565
gemini-cli524
codex478
opencode474
github-copilot407
Build apps on the Base44 platform using the Base44 JavaScript SDK.
This skill activates on ANY mention of "base44" or when a base44/ folder exists. DO NOT read documentation files or search the web before acting.
Your first action MUST be:
base44/config.jsonc exists in the current directoryUse base44-sdk when:
base44/config.jsonc already exists in the project@base44/sdk)DO NOT USE base44-sdk for:
base44-cli instead)npx base44 create, npx base44 deploy, npx base44 login (use base44-cli)Skill Dependencies:
base44-sdk assumes a Base44 project is already initializedbase44-cli is a prerequisite for base44-sdk in new projectsbase44-cli firstState Check Logic: Before selecting this skill, verify:
base44/config.jsonc exists): → Use base44-cli (project initialization needed)// In Base44-generated apps, base44 client is pre-configured and available
// CRUD operations
const task = await base44.entities.Task.create({ title: "New task", status: "pending" });
const tasks = await base44.entities.Task.list();
await base44.entities.Task.update(task.id, { status: "done" });
// Get current user
const user = await base44.auth.me();
// External apps
import { createClient } from "@base44/sdk";
// IMPORTANT: Use 'appId' (NOT 'clientId' or 'id')
const base44 = createClient({ appId: "your-app-id" });
await base44.auth.loginViaEmailPassword("user@example.com", "password");
Before writing ANY Base44 code, verify method names against this table orQUICK_REFERENCE.md.
Base44 SDK has unique method names. Do NOT assume patterns from Firebase, Supabase, or other SDKs.
| ❌ WRONG (hallucinated) | ✅ CORRECT |
|---|---|
signInWithGoogle() | loginWithProvider('google') |
signInWithProvider('google') | loginWithProvider('google') |
auth.google() | loginWithProvider('google') |
signInWithEmailAndPassword(email, pw) |
| ❌ WRONG (hallucinated) | ✅ CORRECT |
|---|---|
functions.call('name', data) | functions.invoke('name', data) |
functions.run('name', data) | functions.invoke('name', data) |
callFunction('name', data) | functions.invoke('name', data) |
httpsCallable('name')(data) |
| ❌ WRONG (hallucinated) | ✅ CORRECT |
|---|---|
ai.generate(prompt) | integrations.Core.InvokeLLM({prompt}) |
openai.chat(prompt) | integrations.Core.InvokeLLM({prompt}) |
llm(prompt) | integrations.Core.InvokeLLM({prompt}) |
sendEmail(to, subject, body) |
| ❌ WRONG (hallucinated) | ✅ CORRECT |
|---|---|
entities.Task.find({...}) | entities.Task.filter({...}) |
entities.Task.findOne(id) | entities.Task.get(id) |
entities.Task.insert(data) | entities.Task.create(data) |
entities.Task.remove(id) |
| Module | Purpose | Reference |
|---|---|---|
entities | CRUD operations on data models | entities.md |
auth | Login, register, user management | auth.md |
agents | AI conversations and messages | base44-agents.md |
functions | Backend function invocation |
For client setup and authentication modes, see client.md.
Each reference file includes a "Type Definitions" section with TypeScript interfaces and types for the module's methods, parameters, and return values.
Getting typed entities, functions, and agents: The Base44 CLI generates types from your project resources (entities, functions, agents), including augmentations to EntityTypeRegistry, FunctionNameRegistry, and AgentNameRegistry, and wires them into your project so you get autocomplete and type checking without manual setup. For how to generate types, use the base44-cli skill.
Manual augmentation: You can instead augment the registries yourself in a .d.ts file; see the Type Definitions sections in entities.md, functions.md, and base44-agents.md.
Install the Base44 SDK:
npm install @base44/sdk
Important: Never assume or hardcode the @base44/sdk package version. Always install without a version specifier to get the latest version.
When creating a client in external apps, ALWAYS useappId as the parameter name:
import { createClient } from "@base44/sdk";
// ✅ CORRECT
const base44 = createClient({ appId: "your-app-id" });
// ❌ WRONG - Do NOT use these:
// const base44 = createClient({ clientId: "your-app-id" }); // WRONG
// const base44 = createClient({ id: "your-app-id" }); // WRONG
Required parameter: appId (string) - Your Base44 application ID
Optional parameters:
token (string) - Pre-authenticated user tokenoptions (object) - Configuration options
options.onError (function) - Global error handlerExample with error handler:
const base44 = createClient({
appId: "your-app-id",
options: {
onError: (error) => {
console.error("Base44 error:", error);
}
}
});
Working with app data?
entitiesentities.importEntities()entities.EntityName.subscribe()User management?
authauth.me()auth.updateMe()users.inviteUser()AI features?
agents (requires logged-in user)agents.createConversation()agents.getConversations()integrations.Core.InvokeLLM()integrations.Core.GenerateImage()Custom backend logic?
functions.invoke()base44.asServiceRole.functions.invoke()External services?
integrations.Core.SendEmail()integrations.Core.UploadFile()integrations.custom.call()connectors (backend only)Tracking and analytics?
analytics.track()appLogs.logUserInApp()const pendingTasks = await base44.entities.Task.filter(
{ status: "pending", assignedTo: userId }, // query
"-created_date", // sort (descending)
10, // limit
0 // skip
);
const user = await base44.auth.me();
if (!user) {
// Navigate to your custom login page
navigate('/login', { state: { returnTo: window.location.pathname } });
return;
}
// Frontend
const result = await base44.functions.invoke("processOrder", {
orderId: "123",
action: "ship"
});
// Backend function (Deno)
import { createClientFromRequest } from "npm:@base44/sdk";
Deno.serve(async (req) => {
const base44 = createClientFromRequest(req);
const { orderId, action } = await req.json();
// Process with service role for admin access
const order = await base44.asServiceRole.entities.Orders.get(orderId);
return Response.json({ success: true });
});
Use asServiceRole in backend functions for admin-level operations:
// User mode - respects permissions
const myTasks = await base44.entities.Task.list();
// Service role - full access (backend only)
const allTasks = await base44.asServiceRole.entities.Task.list();
const token = await base44.asServiceRole.connectors.getAccessToken("slack");
| Capability | Frontend | Backend |
|---|---|---|
entities (user's data) | Yes | Yes |
auth | Yes | Yes |
agents | Yes | Yes |
functions.invoke() | Yes | Yes |
integrations | Yes | Yes |
Backend functions use Deno.serve() and createClientFromRequest(req) to get a properly authenticated client.
Weekly Installs
726
Repository
GitHub Stars
64
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
cursor637
claude-code565
gemini-cli524
codex478
opencode474
github-copilot407
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
Gemini Interactions API 指南:统一接口、智能体交互与服务器端状态管理
833 周安装
Apollo MCP 服务器:让AI代理通过GraphQL API交互的完整指南
834 周安装
智能体记忆系统构建指南:分块策略、向量存储与检索优化
835 周安装
Scrapling官方网络爬虫框架 - 自适应解析、绕过Cloudflare、Python爬虫库
836 周安装
抽奖赢家选取器 - 随机选择工具,支持CSV、Excel、Google Sheets,公平透明
838 周安装
Medusa 前端开发指南:使用 SDK、React Query 构建电商商店
839 周安装
loginViaEmailPassword(email, pw)signIn(email, pw) | loginViaEmailPassword(email, pw) |
createUser() / signUp() | register({email, password}) |
onAuthStateChanged() | me() (no listener, call when needed) |
currentUser | await auth.me() |
functions.invoke('name', data)integrations.Core.SendEmail({to, subject, body})email.send() | integrations.Core.SendEmail({to, subject, body}) |
uploadFile(file) | integrations.Core.UploadFile({file}) |
storage.upload(file) | integrations.Core.UploadFile({file}) |
entities.Task.delete(id)entities.Task.onChange(cb) | entities.Task.subscribe(cb) |
integrations | AI, email, file uploads, custom APIs | integrations.md |
connectors | OAuth tokens (service role only) | connectors.md |
analytics | Track custom events and user activity | analytics.md |
appLogs | Log user activity in app | app-logs.md |
users | Invite users to the app | users.md |
analytics| Yes |
| Yes |
appLogs | Yes | Yes |
users | Yes | Yes |
asServiceRole.* | No | Yes |
connectors | No | Yes |