import { MembraneClient } from '@membranehq/sdk'// With a static tokenconst 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 refreshedconst membrane = new MembraneClient({ fetchToken: async () => { const response = await fetch('/api/membrane-token') const { token } = await response.json() return token },})
// List integrationsconst integrations = await membrane.integrations.find()// Get a specific connectionconst connection = await membrane.connection('hubspot').get()// Run an actionconst result = await membrane.action('create-contact').run({ email: 'jane@example.com', name: 'Jane',})// Open connection UIawait membrane.ui.connect({ integrationKey: 'salesforce' })