Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@freesail/react

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@freesail/react

React frontend for Freesail A2UI SDK

latest
npmnpm
Version
0.9.1
Version published
Weekly downloads
61
-74.79%
Maintainers
1
Weekly downloads
 
Created
Source

@freesail/react

React bindings for Freesail — connects your React app to a Freesail gateway and renders agent-driven UI surfaces.

Installation

npm install @freesail/react @freesail/standard-catalog

Quick Start

import { FreesailProvider, FreesailSurface } from '@freesail/react';
import { standardCatalogComponents, standardCatalogFunctions } from '@freesail/standard-catalog';
import standardCatalogSchema from '@freesail/standard-catalog/dist/standard-catalog.json';

function App() {
  return (
    <FreesailProvider
      gateway="http://localhost:3001"
      catalogs={[{
        namespace: 'https://your-catalog-id/catalogs/your-catalog.json',
        components: standardCatalogComponents,
        functions: standardCatalogFunctions,
        schema: standardCatalogSchema,
      }]}
    >
      <FreesailSurface surfaceId="main" />
    </FreesailProvider>
  );
}

Components

FreesailProvider

Root provider that manages the gateway connection and surface state. Must wrap all FreesailSurface components.

PropTypeRequiredDescription
gatewaystringYesBase gateway URL (e.g. http://localhost:3001)
catalogsCatalogDefinition[]NoCatalogs to register with the provider
transportOptionsobjectNoAdditional transport configuration
additionalCapabilitiesRecord<string, unknown>NoExtra capability key/values advertised to the agent
onConnectionChange(connected: boolean) => voidNoCalled when connection state changes
onError(error: Error) => voidNoCalled when a transport error occurs
onBeforeCreateSurfaceinterceptorNoCalled before honouring an agent createSurface — return { allowed: false } to block
onBeforeUpdateComponentsinterceptorNoCalled before honouring an agent updateComponents — return { allowed: false } to block
onBeforeUpdateDataModelinterceptorNoCalled before honouring an agent updateDataModel — return { allowed: false } to block
onBeforeDeleteSurfaceinterceptorNoCalled before honouring an agent deleteSurface — return { allowed: false } to block

FreesailSurface

Renders a single agent-driven surface. Subscribes to updates automatically.

PropTypeRequiredDescription
surfaceIdstringYesThe surface ID to render
classNamestringNoCSS class for the container element
loadingReactNodeNoShown while the surface has not yet been created by the agent
errorReactNodeNoShown when the catalog is not registered
emptyReactNodeNoShown when the surface exists but has no components

Hooks

HookReturnsDescription
useSurface(surfaceId)Surface | undefinedSubscribe to a surface and re-render on updates
useSurfaceData(surfaceId, path?)T | undefinedRead a value from the surface data model at an optional JSON Pointer path
useAction(surfaceId)dispatchReturns a function to send user actions upstream
useConnectionStatus(){ isConnected }Current gateway connection state
useSurfaces()Surface[]All active surfaces
useSessionId()string | nullSession ID assigned by the gateway after connection

Interceptors

Each onBefore* prop lets you validate or block agent operations before they are applied. Return { allowed: false, message: '...' } to block — the message is sent back to the agent as an error. Return { allowed: true, message: '...' } to allow and also notify the agent with a validation message.

<FreesailProvider
  gateway="http://localhost:3001"
  catalogs={[...]}
  onBeforeCreateSurface={(_surfaceId, _catalogId, _sendDataModel, surfaceManager) => {
    if (surfaceManager.getAllSurfaces().length >= 3) {
      return { allowed: false, message: 'Surface limit reached. Please remove a surface first.' };
    }
    return { allowed: true, message: '' };
  }}
  onBeforeUpdateComponents={(surfaceId, components, surfaceManager) => {
    if (components.length > 50) {
      return { allowed: false, message: 'Too many components' };
    }
    return { allowed: true, message: '' };
  }}
>
  ...
</FreesailProvider>

License

MIT — see LICENSE

Keywords

a2ui

FAQs

Package last updated on 15 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts