Skip to main content

Quickstart

Compose enables developers to turn backend functions into shareable internal tools with just a few lines of code. Build the tools you need to power your business in minutes instead of days.

How Compose Works

The platform has two parts:

  • A lightweight SDK that installs into your backend and lets you write apps using familiar async functions.
  • A hosted dashboard (https://composehq.com) where you run and share the apps you build.

Compose "apps" are just plain async functions within your backend codebase. Write your logic as usual, then add SDK calls to render user interfaces and collect user input. The SDK connects automatically to the Compose dashboard, where Compose manages the API calls, UI rendering, authentication, and more to turn your logic into polished, shareable apps.

The platform includes an extensive library of 40+ components, tested to be performant at enterprise scale, and designed with developer experience at the core.

Let's install the SDK and build our first app in less than 5 minutes.

Installation

Initialize a Node.js project and install the Compose SDK.

# Create a new project
mkdir compose && cd compose
npm init -y
npm pkg set type=module # Use ESM module syntax

# Install the Compose SDK
npm install @composehq/sdk

# Optional: install typescript dependencies
npm install --save-dev typescript tsx

Your First App

Let's build a simple dashboard that displays a list of users. Create a file called app.js (or app.ts), then paste the following code.

import { Compose } from "@composehq/sdk"

const dbUsers = [
{ id: 1, name: "Lisa Su", isApproved: true },
{ id: 2, name: "Jensen Huang", isApproved: false },
{ id: 3, name: "Brian Chesky", isApproved: true },
]

const usersDashboard = new Compose.App({
name: "Users Dashboard",
handler: ({ page, ui }) => {
const users = [...dbUsers]; // Simulate a database query
page.add(() => ui.header("Users Dashboard"))
page.add(() => ui.table("table-id", users))
}
});

const client = new Compose.Client({
apiKey: "API_KEY_HERE",
apps: [usersDashboard]
});

client.connect();

Create a free account on Compose to get an API key. Then, run your app:

node --watch app.js # or tsx app.ts

Go back to the Compose dashboard and your app should appear!

Extend this app to edit users in 17 lines of code

Let's add a button to each row in our table. When clicked, this button will open a form to edit the user.

Replace your previous code with the following:

import { Compose } from "@composehq/sdk"

const dbUsers = [
{ id: 1, name: "Lisa Su", isApproved: true },
{ id: 2, name: "Jensen Huang", isApproved: false },
{ id: 3, name: "Brian Chesky", isApproved: true },
]

const usersDashboard = new Compose.App({
name: "Users Dashboard",
handler: ({ page, ui }) => {
const users = [...dbUsers]; // Simulate a database query

function editUser(user, idx) {
page.modal(({ resolve }) => ui.form(
"edit-user",
[
ui.textInput("name", { initialValue: user.name }),
ui.checkbox("isApproved", { initialValue: user.isApproved }),
],
{
onSubmit: (formData) => {
users[idx] = { ...user, ...formData };
page.update();
resolve(); // Close modal
}
}
))
}

page.add(() => ui.header("Users Dashboard"))
page.add(() => ui.table("table-id", users, {
actions: [{ label: "Edit", onClick: (user, idx) => editUser(user, idx) }]
}))
}
});

const client = new Compose.Client({
apiKey: "API_KEY_HERE",
apps: [usersDashboard]
});

client.connect();

Save your file, and your app should update! Note: you may need to rerun the script if you're not using a --watch flag.

Next Steps

  • Try replacing dbUsers with real data from your own database!
  • Go over Compose's core concepts to quickly become productive with the SDK.
  • Join the Discord community to ask questions and talk to the core team.