SDK Overview
@amodalai/react connects a web application to a deployed Amodal runtime over HTTP and server-sent events.
| Need | Use |
|---|---|
| Add chat to a React app | ChatWidget, available from @amodalai/react/widget. |
| Build a UI with agent actions, sessions, and events | AmodalProvider and hooks. |
| Render inline chat inside a provider | AmodalChat. |
| Call runtime APIs from imperative code | RuntimeClient, SdkClient, or ChatClient. |
Install
npm install @amodalai/reactThe package requires React and React DOM 18 or 19. Import its stylesheet when using the chat components.
Hosted React app
For an app served on the agent's origin with the default team login:
import { AmodalProvider, AmodalChat } from '@amodalai/react';
import '@amodalai/react/style.css';
export function App() {
return (
<AmodalProvider runtimeUrl={window.location.origin}>
<AmodalChat />
</AmodalProvider>
);
}The hosted cookie authenticates same-origin calls. Use direct runtime access when users are trusted to access the agent's sessions across scopes.
For a multi-tenant product, point the SDK at an application proxy that retains runtime credentials and authorizes each scope, session, and operation. Return your application token through getToken, passing the callback separately to the provider and chat component. See Authentication and Embedding.