The open alternative to Salesforce, designed for AI.
How Twenty Apps Work
Use this reference to understand the Twenty application development model before creating, developing, or deploying an app. Other references cover specific workflows; this one explains the architecture behind them.
What Is A Twenty App
A Twenty app is a standalone npm package that extends a Twenty instance. It is not part of the Twenty server codebase. It lives in its own directory with its own package.json, dependencies, and source tree. When installed on a Twenty instance, it adds objects, fields, views, page layouts, front components, logic functions, skills, agents, and more to that workspace.
The app does not run as a separate server. It is built, published, and installed into a running Twenty instance. The instance loads the app's entities into its schema and renders the app's front components inside the workspace UI.
SDK Packages
A Twenty app depends on two SDK packages:
| Package | Purpose | Used in |
|---|---|---|
twenty-sdk |
Define app entities and access front component runtime APIs | Entity definitions (twenty-sdk/define), front component hooks and host APIs (twenty-sdk/front-component) |
twenty-client-sdk |
Access workspace data from front components | Core object queries (twenty-client-sdk/core), metadata queries (twenty-client-sdk/metadata) |
twenty-sdk/define provides the registration functions: defineApplication, defineObject, defineField, defineValidationRule, defineView, definePageLayout, defineFrontComponent, defineSettingsMenuItem, defineNavigationMenuItem, defineLogicFunction, defineRole, and others. Every app entity is declared through one of these functions.
twenty-sdk/front-component provides runtime APIs available inside front components: navigate, enqueueSnackbar, openSidePanelPage, useSelectedRecordIds, getApplicationVariable, and others.
Twenty UI components (Button, Chip, Tag, Status, Heading, Section, ThemeProvider, icons, themeCssVariables) live in the twenty-ui package. Install twenty-ui from npm at the same version as twenty-sdk and twenty-client-sdk and import from its subpaths (twenty-ui/primitives/input, twenty-ui/primitives/data-display, twenty-ui/icon, twenty-ui/primitives/typography, twenty-ui/components, twenty-ui/theme, and others).
twenty-client-sdk/core provides CoreApiClient for querying and mutating workspace records (companies, people, custom objects). twenty-client-sdk/metadata provides access to workspace metadata (object definitions, field definitions).
Twenty Instances And Remotes
A Twenty instance is a running Twenty server — either self-hosted or managed cloud. Each instance hosts one or more workspaces. Apps are installed per workspace.
A "remote" is the local CLI's connection to a Twenty instance. The standalone CLI stores its server URL and credentials locally. You can configure multiple remotes (e.g. local, staging, production) and switch between them.
The API key authenticates the developer against the target workspace. It determines which workspace the app syncs to, deploys to, and reads data from during development.
Local Development Environment
Connect to an existing Twenty workspace with twenty auth login --url <twenty-instance-url> --name dev. This opens browser authentication and saves a remote.
For local development, run twenty local start to create or start the full Twenty environment, then authenticate against http://localhost:2020. Docker must be installed and running. Use --test for a separate instance on port 2021. The repository's development environment remains an alternative.
App Lifecycle
The development loop is:
create → develop → sync → validate → repeat
Create:
twenty app init <app-name>generates source files. Then install dependencies withyarn install, authenticate withtwenty auth login, and explicitly runtwenty app apply --createfor the first sync.Develop: Add or modify entities in
src/. Objects go insrc/objects/, front components insrc/front-components/, logic functions insrc/logic-functions/, page layouts insrc/page-layouts/, and so on. Each entity file exports adefine*call.Sync:
twenty app applybuilds, deploys, and installs the app on the active remote in one step. The Twenty instance updates its schema, registers new objects and fields, mounts front components, and activates logic functions. This is the primary way to get changes onto a Twenty instance during development. Sync after every meaningful change.Validate:
twenty app typecheckchecks generated types.yarn lintchecks local lint rules. Open the workspace in a browser to verify front components render and logic functions execute.
Sharing An App
Publishing is separate from the development loop. It is used to share an app with other Twenty instances or the public marketplace:
twenty app publishpublishes to npm for the public marketplace.twenty app publish --private --remote <name>publishes privately to a specific Twenty instance's registry.
Each publish requires a strictly higher semver version in package.json. See the publish-app skill for marketplace metadata and listing guidance.
Front Component Rendering
Front components do not run as a separate frontend application. The Twenty workspace renders them inside an isolated Remote DOM container. The SDK mounts the component, provides a ThemeProvider, and proxies host APIs (navigation, snackbars, side panels) through twenty-sdk/front-component.
This means:
- Front components cannot access
documentorwindowglobals directly. - They cannot use React portals or third-party libraries that manipulate the DOM outside their tree.
- They import UI primitives from
twenty-ui(installed from npm), not from external component libraries. - They fetch workspace data through
twenty-client-sdk/core, not through direct API calls.
For microphone or camera capture, declare requestedCapabilities: ['microphone'], ['camera'], or ['microphone', 'camera'] in defineApplication(). These capabilities appear during installation and are separate from role permissions. Approval requires a workspace member who can manage apps and applies to the whole workspace.
Calling navigator.mediaDevices.getUserMedia() without a saved grant pauses capture and shows an approval dialog, including for older apps without requestedCapabilities. Declining leaves capture blocked before browser permissions are requested. Package updates do not automatically add grants; locally synced development apps receive their declared capabilities. Browser and operating system permissions still apply after workspace approval.
An embedded website such as a phone or video tool needs its exact HTTPS origin declared in requestedIframeMediaPermissions in defineApplication(), with microphone and camera set separately: [{ origin: 'https://phone.example.com', microphone: true, camera: false }]. Declared websites appear during installation for the same workspace-wide approval. Locally synced development apps receive their declared iframe origins automatically. Updates to published apps preserve existing grants and do not automatically grant additional media access. A member who can manage apps can approve new requests from the installed app's General tab, under Embedded website media access > Review media access. This approval uses a native browser confirmation showing the app, website origins, and requested microphone or camera access. After approving, reload open Twenty tabs to apply the updated permissions. Front-component iframes must request the features (allow="microphone" or allow="microphone; camera"). App-defined IFRAME page layout widgets use the owning app's grants instead of workspace security approvals or other apps' grants. Twenty delegates only to granted origins, and only after a member selects the embed's Enable control and approves a native browser confirmation showing the app, website origin, and requested microphone or camera access. srcDoc iframes and embeds at Twenty's own origin never receive media access.
App File Structure
A typical Twenty app after scaffolding:
my-app/
package.json # App metadata, version, dependencies
src/
application-config.ts # defineApplication() — app identity and marketplace metadata
constants/
universal-identifiers.ts # Stable UUIDs for all entities
objects/ # defineObject, defineField, defineRelation
validation-rules/ # defineValidationRule
views/ # defineView
roles/ # defineRole
front-components/ # defineFrontComponent (.tsx)
settings-menu-items/ # defineSettingsMenuItem
page-layouts/ # definePageLayout
navigation-menu-items/ # defineNavigationMenuItem
logic-functions/ # defineLogicFunction
public/ # Static assets (logos, screenshots, images)
.github/workflows/ # CI/CD automation (optional)
application-config.ts is the app's entry point. It calls defineApplication() with the app's universal identifier, display name, description, default role, and marketplace metadata. Every entity references stable UUIDs from constants/universal-identifiers.ts.
Key Concepts
- Universal identifiers: Stable UUIDs assigned to every entity. They survive renames, version bumps, and resyncs. Never change a universal identifier after first sync.
- Remotes: Named connections to Twenty instances. Stored in
~/.twenty/config.json. Switch withtwenty remote use <name>. - Sync:
twenty app applybuilds, deploys, and installs the app on the active remote in one step. This is the standard way to get code changes onto a Twenty instance. - Publish:
twenty app publishpackages the app for distribution to other instances or the marketplace. Requires a strictly higher semver version than the previously published version. - Reserved variable names:
TWENTY_API_URL,TWENTY_APP_ACCESS_TOKEN,TWENTY_APP_APPLICATION_ACCESS_TOKEN,TWENTY_API_KEY,TWENTY_FUNCTIONS_URL,TWENTY_SERVER_ROUTES_URLandAPPLICATION_IDare set by Twenty for every logic function run, and every other name starting withTWENTY_is kept for variables Twenty adds later. A manifest that declares a reserved name as an application or server variable is rejected on sync and publish.