Instant CLI
raw JSON →The Instant CLI is a command-line interface tool designed to manage applications built with InstantDB, a real-time, schema-defined backend-as-a-service. It enables developers to perform various operations directly from the terminal, including authenticating with their Instant account, initializing new Instant applications, defining and evolving data models via `instant.schema.ts` files, and managing permissions through `instant.perms.ts` files. The CLI is actively maintained, with frequent updates, and currently stable at version 1.0.14. Key differentiators include its tight integration with the InstantDB platform, support for LLM agents to programmatically interact with the backend, and features for both local development and CI/CD pipelines, emphasizing a code-first approach to backend management.
Common errors
error unknown command 'create-app' ↓
npx instant-cli@latest init to initialize a new project, or npx create-instant-app to scaffold a new application. error Error: Command failed with exit code 1: instant-cli login ↓
npx instant-cli@latest for reliable execution. If using a global install, run npm install -g instant-cli. error INVALID DATA adding required constraint to <entity>.<attribute> ↓
error Permission denied: not perms-pass? ↓
instant.perms.ts file to ensure the correct permission rules are in place for the user/token. Use npx instant-cli@latest login -p to get a token with appropriate permissions, or use --admin flag for administrative operations in development contexts. Warnings
gotcha When renaming an attribute or link in your `instant.schema.ts` and performing a `push` operation, the CLI will interactively prompt you to confirm if it's a rename or a delete/create operation. This can halt automated CI/CD pipelines. ↓
breaking The `create-app` command, previously mentioned in some documentation, is no longer directly available as `npx instant-cli create-app`. Project creation is now handled either by `npx instant-cli init` or the external `npx create-instant-app` utility. ↓
gotcha For continuous integration (CI) environments, interactive login is not feasible. Authentication requires providing an `INSTANT_CLI_AUTH_TOKEN` environment variable, which needs to be obtained through a specific non-interactive login flow. ↓
gotcha Queries and transactions executed through InstantDB, whether via the CLI or SDKs, have inherent timeout limits (e.g., 5 seconds for client SDK, 30 seconds for admin SDK/sandbox). Exceeding these limits results in timeout errors, impacting application performance and reliability. ↓
Install
npm install instant-cli yarn add instant-cli pnpm add instant-cli Imports
- Login wrong
instant-cli logincorrectnpx instant-cli@latest login - Init wrong
npx instant-cli@latest create-appcorrectnpx instant-cli@latest init - PushSchema wrong
npx instant-cli pushcorrectnpx instant-cli@latest push schema
Quickstart
#!/bin/bash
# Ensure npx is available
if ! command -v npx &> /dev/null
then
echo "npx not found. Please install Node.js and npm/npx." >&2
exit 1
fi
echo "Logging into InstantDB... A browser window will open for authentication."
npx instant-cli@latest login
echo "Initializing a new InstantDB project..."
# This will prompt you to select an app and generate instant.schema.ts and instant.perms.ts
npx instant-cli@latest init
# Example: Create a simple schema file (instant.schema.ts)
echo 'import { i } from "@instantdb/react";\n\nconst schema = i.schema({\n entities: {\n todos: i.entity({\n text: i.string(),\n done: i.boolean().default(false),\n createdAt: i.number().default(() => Date.now()),\n }),\n },\n});\n\nexport default schema;\n' > instant.schema.ts
echo "Pushing schema changes to InstantDB..."
npx instant-cli@latest push schema
echo "Done! Your InstantDB project is set up and schema pushed. You can now use `npx instant-cli@latest --help` for more commands."