Skip to main content
Version: 0.4.x

JavaScript Client

Interact with ComposeDB using JavaScript, TypeScript, or React.


The client exposes the primary APIs to interact with ComposeDB from your application using a compiled composite.


Install the ComposeDB client package:

pnpm add @composedb/client

If you’re using TypeScript, you may also need to install ComposeDB Types:

pnpm add -D @composedb/types


Create a client instance by passing your server URL and your compiled composite:

// Import ComposeDB client

import { ComposeClient }from '@composedb/client'

// Import your compiled composite

import { definition }from './__generated__/definition.js'

// Create an instance of ComposeClient
// Pass the URL of your Ceramic server
// Pass reference to your compiled composite

const compose = new ComposeClient({ ceramic: 'http://localhost:7007', definition })

More details: ComposeClient


Executing Queries

Execute GraphQL Queries using the schema that is auto-generated from your compiled composite:

// Get account of authenticated user

await compose.executeQuery(`
query {
viewer {

More details: executeQuery


Enabling Mutations

Before enabling mutations you must Authenticate Users. After you have an authenticated user, enable Mutations by setting their authenticated account on the ComposeDB client:

// Assign the authorized did from your session to your client


Executing mutations

In your client, you can execute GraphQL mutations using the schema that is auto-generated from your compiled composite. You can follow examples in the Data Interactions guides to learn more about performing Queries and Mutations.

Next Steps

  • ComposeDB’s JavaScript client optionally works with popular GraphQL clients like Apollo or Relay.