Skip to Content

API Reference

Complete reference for the @getpassage/web-react SDK.

React API

PassageProvider

Context provider that renders the App Clip modal and manages WebSocket connections. Wrap your app or the relevant subtree.

import { PassageProvider } from '@getpassage/web-react'; <PassageProvider> <App /> </PassageProvider>
PropTypeDefaultDescription
childrenReactNodeChild components

usePassage

Hook that returns functions to control the App Clip modal. Must be used within a PassageProvider.

import { usePassage } from '@getpassage/web-react'; const { openAppClip, close } = usePassage();
FieldTypeDescription
openAppClip(options: OpenAppClipOptions) => voidOpen the modal with a QR code and start monitoring link status
close() => voidClose the modal and stop monitoring

Types

OpenAppClipOptions

Options passed to openAppClip().

FieldTypeRequiredDescription
claimCodestringYesClaim code from POST /v1/links (e.g. "clm_xxx")
onConnectionComplete() => voidNoCalled when the link reaches complete status
onConnectionError(error: PassageErrorData) => voidNoCalled when the link reaches failed or expired status

PassageErrorData

Error object passed to onConnectionError.

FieldTypeDescription
errorstringError message
codestring | undefinedError code (e.g. "AUTOMATION_ERROR", "CLIENT_TIMEOUT")

Standalone API

For non-React usage or imperative control outside of React components. These functions dispatch DOM events that PassageProvider listens for, so a provider must still be mounted in the React tree.

openAppClip

Open the App Clip modal. Dispatches a DOM event that PassageProvider handles.

import { openAppClip } from '@getpassage/web-react'; openAppClip({ claimCode: 'clm_xxx', onConnectionComplete: () => console.log('done'), onConnectionError: (err) => console.error(err), });

close

Close the modal and stop monitoring.

import { close } from '@getpassage/web-react'; close();

Next steps

Last updated on