> ## Documentation Index
> Fetch the complete documentation index at: https://docs.membrane.agency/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript SDK

The Membrane JavaScript SDK provides typed accessors for all Membrane resources. It works in both Node.js and browser environments.

## Install

```bash theme={null}
npm install @membranehq/sdk
```

## Initialize

```javascript theme={null}
import { MembraneClient } from '@membranehq/sdk'

// With a static token
const membrane = new MembraneClient({
  token: process.env.MEMBRANE_ACCESS_TOKEN,
})

// With dynamic token fetching — for long-lived environments (like web pages)
// where the token may expire and needs to be refreshed
const membrane = new MembraneClient({
  fetchToken: async () => {
    const response = await fetch('/api/membrane-token')
    const { token } = await response.json()
    return token
  },
})
```

See [Authentication](/docs/how-membrane-works/authentication) for how to get an access token.

## Usage

```javascript theme={null}
// List integrations
const integrations = await membrane.integrations.find()

// Get a specific connection
const connection = await membrane.connection('hubspot').get()

// Run an action
const result = await membrane.action('create-contact').run({
  email: 'jane@example.com',
  name: 'Jane',
})

// Open connection UI
await membrane.ui.connect({ integrationKey: 'salesforce' })
```

## SDK Reference

See the [SDK Reference](https://console.getmembrane.com/ref/sdk/index.html) for the full list of accessors, methods, and types.
