Building a Twenty App (SDK Guide)
Relevant source files
The following files were used as context for generating this wiki page:
- packages/twenty-sdk/src/index.ts
- packages/twenty-sdk/src/application/application-config.ts
- packages/twenty-apps/hello-world/application.config.ts
- packages/twenty-sdk/src/cli/cli.ts
- packages/create-twenty-app/README.md
- packages/twenty-sdk/README.md
- packages/twenty-cli/README.md
- packages/twenty-apps/hello-world/README.md
- packages/create-twenty-app/src/constants/base-application/README.md
The Twenty ecosystem provides a powerful Software Development Kit (SDK) and scaffolding tools to extend the core CRM functionality. Developers can build custom applications that introduce new objects, serverless functions, and logic that integrate seamlessly with a Twenty workspace. The primary tools for this are the create-twenty-app package for project scaffolding and the twenty-sdk for development and synchronization.
This guide outlines the process of creating, developing, and managing a Twenty application using these official tools. It covers the initial setup, the development workflow, the command-line interface (CLI), and the process for publishing an application. The entire workflow is designed to be zero-config and type-safe, enabling rapid development and integration.
Sources: packages/create-twenty-app/README.md, packages/twenty-sdk/README.md
Getting Started
Prerequisites
Before you can start building a Twenty app, you need to have the following tools and credentials set up in your development environment.
| Prerequisite | Description |
|---|---|
| Node.js | Version 24+ is recommended. |
| Yarn | Version 4 is required. |
| Twenty Workspace | A running instance of Twenty CRM. |
| API Key | An API key generated from your Twenty workspace settings (/settings/api-webhooks). |
Sources: packages/create-twenty-app/README.md:19-21, packages/twenty-sdk/README.md:18-20
Scaffolding a New App
The quickest way to start a new Twenty application is by using the create-twenty-app command-line tool. This tool bootstraps a new project with a minimal, ready-to-run structure.
To create a new app, run the following command:
npx create-twenty-app@latest my-twenty-app
cd my-twenty-app
This command scaffolds a new directory (my-twenty-app) containing:
- A minimal app structure ready for Twenty.
- TypeScript configuration.
- Pre-wired
package.jsonscripts that wrap thetwenty-sdkCLI. - Example placeholders for entities, actions, and sync logic.
Sources: packages/create-twenty-app/README.md:24-25, packages/create-twenty-app/README.md:40-44
The Twenty SDK and CLI
The twenty-sdk package is the core of app development. It provides both a library for programmatic access and a command-line interface (CLI) named twenty for managing the application lifecycle. While you can use the twenty CLI directly, create-twenty-app pre-configures yarn scripts that wrap these commands for convenience.
Note: The older twenty-cli package is deprecated and has been replaced by twenty-sdk. The command name twenty remains the same.
Sources: packages/twenty-sdk/README.md:14, packages/twenty-cli/README.md:3-7
Core CLI Commands
The CLI provides several commands to manage the authentication, development, and deployment of your application.
| Command (Yarn Script) | Direct Command | Description |
|---|---|---|
yarn auth | twenty auth login | Authenticates the CLI with your Twenty workspace using an API key. |
yarn create-entity | twenty app add | A guided process to add a new entity (object, function, etc.) to your application. |
yarn generate | twenty app generate | Generates a typed Twenty client and TypeScript definitions for your workspace entities. |
yarn dev | twenty app dev | Starts development mode, which automatically syncs local file changes to your workspace. |
yarn sync | twenty app sync | Performs a one-time sync of your local application changes to the workspace. |
yarn logs | twenty app logs | Watches and displays logs for your application's functions. |
yarn uninstall | twenty app uninstall | Uninstalls the application from the currently authenticated workspace. |
yarn help | twenty help | Displays help information for all available commands. |
Sources: packages/create-twenty-app/READMEmd:28-38, packages/twenty-sdk/README.md:31-44
Development Workflow
The development process for a Twenty app follows a clear, iterative cycle. The diagram below illustrates the typical workflow from scaffolding a new project to seeing it live in your workspace.
This diagram shows the typical developer workflow for creating and syncing a Twenty application.
The following sequence diagram details the interaction between the developer, the CLI, and the Twenty API during a dev or sync operation.
Application Structure
A Twenty application has a defined structure. The hello-world example demonstrates a minimal setup.
hello-world/
├── application.config.ts # Main application definition file
├── package.json # Project dependencies and scripts
├── README.md # App documentation
└── serverlessFunctions/ # Custom backend logic
└── create-new-post-card/
├── index.ts # Function implementation
└── trigger.json # Function triggers (e.g., API route, DB event)
Sources: packages/twenty-cli/README.md:44-49, packages/twenty-apps/hello-world/README.md:28-34
application.config.ts
This file is the manifest for your application. It defines metadata such as the app's name, description, and icon.
Here is an example from the hello-world app:
import { defineApplication } from 'twenty-sdk';
export default defineApplication({
name: 'Hello World',
description: 'A minimal hello-world application.',
icon: 'https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-apps/hello-world/assets/icon.png',
});
The defineApplication function is imported from the twenty-sdk and ensures the configuration object conforms to the required structure.
Sources: packages/twenty-apps/hello-world/application.config.ts:1-7, packages/twenty-sdk/src/application/application-config.ts:4-6
Publishing an Application
Currently, community applications are stored within the main Twenty monorepo under packages/twenty-apps. To share your application with all Twenty users, you must submit it via a pull request to the twentyhq/twenty GitHub repository.
The process is as follows:
- Clone the
twentyhq/twentyrepository. - Create a new feature branch (e.g.,
feature/my-awesome-app). - Copy your completed application folder into
packages/twenty-apps. - Commit your changes and open a pull request.
The Twenty team reviews all contributions for quality, security, and reusability before merging.
Sources: packages/create-twenty-app/README.md:48-63, packages/twenty-sdk/README.md:50-65
Summary
The Twenty SDK and create-twenty-app scaffolder provide a comprehensive and developer-friendly toolchain for extending the Twenty CRM. By leveraging these tools, developers can quickly bootstrap, develop, and sync custom applications with type-safety and minimal configuration. The workflow is centered around a powerful CLI that handles authentication, code generation, and synchronization, allowing developers to focus on building valuable features for their workspace.
Sources: packages/create-twenty-app/README.md:13-16, packages/twenty-sdk/README.md:14-16