用途:以 InstantDB 作为后端,构建完整可用的 React、原生 JS 或 Expo 应用。
主要能力:Instant 是客户端数据库,内置查询、事务、认证、权限、存储、实时与离线支持。SDK 包括 @instantdb/core(原生 JS)、@instantdb/react(React)、@instantdb/react-native(React Native/Expo)、@instantdb/admin(后端脚本/服务器)。
使用方式:安装前先确认项目使用的包管理器(npm、pnpm、bun),再安装最新版 SDK。React 项目默认使用 Next 与 Tailwind(除非另有说明)。查找 instant.schema.ts 与 instant.perms.ts 以及环境文件中的 app id 和 admin token。新建应用:npx instant-cli init-without-files --title <APP_NAME>;未登录时先在 https://instantdb.com 注册或登录,再运行 npx instant-cli login,然后重跑初始化命令。已有 app id/admin token 但无 schema/perm 文件时:npx instant-cli pull --yes。修改 instant.schema.ts 后推送:npx instant-cli push schema --yes;重命名字段:npx instant-cli push schema --rename 'posts.author:posts.creator stores.owner:stores.manager' --yes。修改 instant.perms.ts 后推送:npx instant-cli push perms --yes。CLI 临时查询:npx instant-cli query '{ posts: {} }' --admin,需上下文标志 --admin、--as-email <email> 或 --as-guest,也支持 --app <id>。
限制与注意:React 中须遵守 hooks 规则,不能条件调用 hooks。过滤或排序的字段必须在 schema 中建立索引,否则报错;排序不能用于嵌套属性。where 过滤仅支持等值、$ne、$isNull、$gt/$lt/$gte/$lte、$in、$like/$ilike、and/or 与嵌套字段,没有 $exists、$nin、$regex。分页键(limit、offset、first、after、last、before)只能用于顶层命名空间。权限中 data.ref 返回列表且必须以属性结尾,auth.ref 路径须以 $user 开头;$users 默认 view 为 auth.id == data.id,update/delete 默认 false,create 默认 true 且不可覆盖 delete;$files 默认全部 false,且 data.ref 不适用于 $files。初始化 Instant 时应传入 schema 以获得类型安全,使用 id() 生成新实体 id,并使用 Instant 工具类型标注数据模型。
适用场景:需要实时、离线、认证与权限的客户端应用,以及用 Admin SDK 编写种子或重置脚本。具体收费、价格与平台信息暂未提供。