Airweave Connect

Let your users connect their own data sources with a pre-built, embeddable UI component. No auth UI to build.

Airweave Connect is a hosted, embeddable UI widget that lets end users connect their apps (Slack, GitHub, Google Drive, Notion, and more) directly inside your product. Think of it like Plaid for data integrations: you add a button, your users click it, and their data starts syncing.

No auth UI to build

OAuth flows, credential forms, and connection management are all handled for you.

Fully themeable

Match your brand with custom colors, fonts, and dark/light mode support.

Works anywhere

React hook, vanilla JS class, or raw iframe. Integrate however you like.


How it works

The widget runs inside an iframe hosted by Airweave. Your backend creates a short-lived session token, your frontend passes it to the widget via postMessage, and the widget handles the rest.

┌────────────────────────────────────────────────────────────────┐
│ Your Application │
│ │
│ [Connect your apps] ──onClick──► Airweave Connect modal │
│ ┌──────────────────────┐ │
│ │ ● Slack │ │
│ │ ● GitHub │ │
│ │ ● Google Drive │ │
│ │ ... │ │
│ └──────────────────────┘ │
└────────────────────────────────────────────────────────────────┘

The flow in three steps:

1

Your backend creates a session

Call POST /connect/sessions with your API key. This returns a short-lived session token scoped to a specific collection and optionally restricted to certain integrations.

2

Your frontend opens the widget

Pass the session token to the Connect widget via your SDK of choice. The widget requests the token, validates it against the Airweave API, and shows the integration picker.

3

Your user connects their app

The widget handles OAuth flows, credential forms, and connection management entirely. Once a connection is created, your app receives a callback with the connection ID.


Quickstart

1. Create a Connect session (server-side)

Your backend creates a session token by calling the Airweave API with your API key. Never expose your API key to the browser.

1import requests
2
3def create_connect_session(collection_id: str, user_id: str) -> str:
4 response = requests.post(
5 "https://api.airweave.ai/connect/sessions",
6 headers={
7 "X-API-Key": "YOUR_API_KEY",
8 "Content-Type": "application/json",
9 },
10 json={
11 "readable_collection_id": collection_id,
12 "mode": "all",
13 "end_user_id": user_id,
14 },
15 )
16 return response.json()["session_token"]

The response contains the session token:

1{
2 "session_id": "550e8400-e29b-41d4-a716-446655440000",
3 "session_token": "eyJ...",
4 "expires_at": "2024-01-01T00:10:00Z"
5}

Session tokens expire after 10 minutes by default (extended to 30 minutes during OAuth flows). Create a new token each time you open the modal. The React and JS SDKs handle this automatically via the getSessionToken callback.


2. Add the Connect widget (client-side)

Choose the integration method that fits your stack:

Install the React package:

$npm install @airweave/connect-react

Use the useAirweaveConnect hook in your component:

1import { useAirweaveConnect } from "@airweave/connect-react";
2
3export function ConnectButton() {
4 const { open, isLoading } = useAirweaveConnect({
5 getSessionToken: async () => {
6 // Call your backend. Never hardcode API keys here.
7 const res = await fetch("/api/airweave/session", { method: "POST" });
8 const data = await res.json();
9 return data.session_token;
10 },
11 onSuccess: (connectionId) => {
12 console.log("New connection created:", connectionId);
13 },
14 onClose: (reason) => {
15 console.log("Modal closed:", reason); // "success" | "cancel" | "error"
16 },
17 });
18
19 return (
20 <button onClick={open} disabled={isLoading}>
21 {isLoading ? "Loading..." : "Connect your apps"}
22 </button>
23 );
24}

Session modes

The mode parameter controls what users can do inside the widget:

ModeCreate connectionsView connectionsDelete connectionsRe-authenticate
all
connect
manage
reauth

Use connect when onboarding new users, manage for a settings page, and reauth when a connection needs its credentials refreshed.


Restricting integrations

Use allowed_integrations to limit which sources appear in the widget. Pass a list of connector short names:

1{
2 "readable_collection_id": "my-collection-abc123",
3 "mode": "connect",
4 "allowed_integrations": ["slack", "github", "google_drive", "notion"]
5}

If allowed_integrations is omitted, all available connectors are shown.


Theme customization

Pass a theme object to match the widget to your brand. Supports separate palettes for dark and light modes.

1const { open } = useAirweaveConnect({
2 getSessionToken,
3 theme: {
4 mode: "dark", // "light" | "dark" | "system"
5 colors: {
6 dark: {
7 primary: "#6366f1",
8 background: "#0f172a",
9 surface: "#1e293b",
10 text: "#ffffff",
11 textMuted: "#9ca3af",
12 border: "#334155",
13 success: "#22c55e",
14 error: "#ef4444",
15 },
16 light: {
17 primary: "#4f46e5",
18 background: "#ffffff",
19 surface: "#f8fafc",
20 text: "#1f2937",
21 textMuted: "#6b7280",
22 border: "#e5e7eb",
23 success: "#22c55e",
24 error: "#ef4444",
25 },
26 },
27 },
28});

You can also update the theme while the modal is open:

1const { setTheme } = useAirweaveConnect({ getSessionToken });
2
3// Call at any time, takes effect immediately
4setTheme({ mode: "light" });

Event callbacks

CallbackSignatureWhen it fires
onSuccess(connectionId: string) => voidA connection was successfully created
onConnectionCreated(connectionId: string) => voidSame as onSuccess (alias)
onClose(reason: "success" | "cancel" | "error") => voidThe modal was closed for any reason
onError(error: SessionError) => voidA session or network error occurred
onStatusChange(status: SessionStatus) => voidThe session status changed inside the widget

SDK reference

React: useAirweaveConnect(options)

Options:

OptionTypeRequiredDescription
getSessionToken() => Promise<string>YesCalled each time the modal opens to fetch a fresh session token
themeConnectThemeNoVisual theme configuration
connectUrlstringNoOverride the Connect widget URL (for self-hosted deployments)
onSuccess(connectionId: string) => voidNoCalled when a connection is created
onError(error: SessionError) => voidNoCalled on errors
onClose(reason: string) => voidNoCalled when the modal closes
onConnectionCreated(connectionId: string) => voidNoAlias for onSuccess
onStatusChange(status: SessionStatus) => voidNoCalled on session status changes
initialView"connections" | "sources" | "configure"NoWhich view to show when the modal opens
modalStyleModalStyleNoOverride modal dimensions and border radius
showCloseButtonbooleanNoShow a close button inside the modal (default: false)

Returns:

PropertyTypeDescription
open() => voidOpen the Connect modal
close() => voidClose the Connect modal
setTheme(theme: ConnectTheme) => voidUpdate the theme while the modal is open
navigate(view: NavigateView) => voidNavigate to a specific view
isOpenbooleanWhether the modal is currently open
isLoadingbooleanWhether a session token is being fetched
errorSessionError | nullCurrent error, if any
statusSessionStatus | nullCurrent session status from the widget

Vanilla JS: new AirweaveConnect(config)

The AirweaveConnect class accepts the same options as the React hook. Key methods:

MethodDescription
open()Open the modal (fetches a session token first)
close()Close the modal
setTheme(theme)Update the theme while the modal is open
navigate(view)Navigate to a specific view
getState()Returns { isOpen, isLoading, error, status }
updateConfig(config)Update callbacks or options after initialization
destroy()Clean up all resources

Session API reference

POST /connect/sessions

Creates a Connect session. Requires an API key.

Request body:

FieldTypeRequiredDescription
readable_collection_idstringYesThe collection users will connect sources to
mode"all" | "connect" | "manage" | "reauth"NoControls available actions (default: "all")
allowed_integrationsstring[]NoLimit which connectors are shown (e.g. ["slack", "github"])
end_user_idstringNoYour internal user ID for audit logging

Response:

FieldTypeDescription
session_idstringUnique session identifier
session_tokenstringHMAC-signed token to pass to the widget
expires_atstringISO 8601 expiry timestamp (10 minutes by default)

Security

  • Session tokens are HMAC-signed and expire after 10 minutes. Create a new token for each modal open. The SDKs handle this automatically.
  • API keys must only be used server-side. Never include them in frontend code or responses.
  • Collection scoping: the collection is bound to the session at creation time. The widget cannot escalate to other collections.
  • allowed_integrations lets you restrict which connectors are visible, reducing your attack surface.
  • Origin validation: the Connect widget validates postMessage origins. Once it receives the first token from your app, it only accepts subsequent messages from that same origin.

Self-hosting

If you’re running Airweave on your own infrastructure, set connectUrl to point at your self-hosted Connect widget:

1const { open } = useAirweaveConnect({
2 getSessionToken,
3 connectUrl: "https://connect.your-domain.com",
4});

You’ll also need to point the Connect widget’s API_URL environment variable at your self-hosted Airweave API:

$docker run -p 8082:8082 \
> -e API_URL=https://api.your-domain.com \
> ghcr.io/airweave-ai/connect:latest

Try it in the playground

The Connect Playground in the Airweave dashboard lets you configure a session, customize the theme, pick allowed integrations, and preview the widget before writing a line of code. It also generates ready-to-use backend and frontend snippets you can copy directly into your app.