Using npm packages
You can install and use any npm package in your app. Both logic functions and front components are bundled with esbuild, which inlines all dependencies into the output — nonode_modules are needed at runtime.
Installing a package
src/logic-functions/fetch-data.ts
src/front-components/chart.tsx
How bundling works
The build step uses esbuild to produce a single self-contained file per logic function and per front component. All imported packages are inlined into the bundle. Logic functions run in a Node.js environment. Node built-in modules (fs, path, crypto, http, etc.) are available and do not need to be installed.
Front components run in a Web Worker. Node built-in modules are not available — only browser APIs and npm packages that work in a browser environment.
Both environments have twenty-client-sdk/core and twenty-client-sdk/metadata available as pre-provided modules — these are not bundled but resolved at runtime by the server.
Setup
The scaffolded app already includes Vitest. If you set it up manually, install the dependencies:vitest.config.ts at the root of your app:
vitest.config.ts
src/__tests__/setup-test.ts
Programmatic SDK APIs
Thetwenty-sdk/cli subpath exports functions you can call directly from test code:
| Function | Description |
|---|---|
appBuild | Build the app and optionally pack a tarball |
appDeploy | Upload a tarball to the server |
appInstall | Install the app on the active workspace |
appUninstall | Uninstall the app from the active workspace |
success: boolean and either data or error.
Writing an integration test
Here is a full example that builds, deploys, and installs the app, then verifies it appears in the workspace:src/__tests__/app-install.integration-test.ts
Running tests
Make sure your local Twenty server is running, then:Type checking
You can also run type checking on your app without running tests:tsc --noEmit and reports any type errors.
CI with GitHub Actions
The scaffolder generates a ready-to-use GitHub Actions workflow at.github/workflows/ci.yml. It runs your integration tests automatically on every push to main and on pull requests.
The workflow:
- Checks out your code
- Spins up a temporary Twenty server using the
twentyhq/twenty/.github/actions/spawn-twenty-docker-imageaction - Installs dependencies with
yarn install --immutable - Runs
yarn testwithTWENTY_API_URLandTWENTY_API_KEYinjected from the action outputs
.github/workflows/ci.yml
spawn-twenty-docker-image action starts an ephemeral Twenty server directly in the runner and outputs the connection details. The GITHUB_TOKEN secret is provided automatically by GitHub.
To pin a specific Twenty version instead of latest, change the TWENTY_VERSION environment variable at the top of the workflow.