Saved Opportunities Widget – React SDK

Install the Saved Opportunities Widget as an NPM package for first-class React (and TypeScript) support. Supports authenticated access via postMessage, auto-refresh, and full CSS variable theming.

Installation

npm install @legionhandtech/lht-react-widgets

React 17+ is a peer dependency. If your project already has React installed you're good to go.

Quick Start

1import { LegionSavedOpportunities } from '@legionhandtech/lht-react-widgets'; 2 3function App() { 4 return ( 5 <LegionSavedOpportunities 6 baseUrl="https://your-legion-domain.com" 7 authToken="your-jwt-token" 8 theme="light" 9 /> 10 ); 11}

You can also import from the dedicated sub-path:

import { LegionSavedOpportunities } from '@legionhandtech/lht-react-widgets/saved-opportunities';

Props Reference

Core Props

PropTypeDefaultDescription
baseUrlstringrequiredBase URL of your Legion deployment
authTokenstringJWT / API key for authenticated access (sent via postMessage, never in URL)
theme"light" | "dark""light"Theme preset
widthstring"100%"Widget width (CSS value)
heightstring"400px"Widget height (CSS value)
classNamestringCSS class applied to the outer container
styleReact.CSSPropertiesInline styles merged into the container
onLoad(detail) => voidCalled when the widget iframe finishes loading
onError(message: string) => voidCalled if the widget iframe fails to load

Theming Props (selection)

All 29 theming props are optional. Here are the most commonly used ones:

PropCSS VariableExample
savedPrimaryColor--saved-primary-color"#228be6"
savedAccentColor--saved-accent-color"#ff6b6b"
savedBackgroundColor--saved-background-color"#ffffff"
savedTextColor--saved-text-color"#1a1b1e"
savedCardBg--saved-card-bg"#ffffff"
savedCardRadius--saved-card-radius"8px"
savedBorderRadius--saved-border-radius"12px"
savedFontFamily--saved-font-family"Inter, sans-serif"
savedButtonBg--saved-button-bg"#228be6"
savedButtonColor--saved-button-color"#ffffff"
savedHoverScale--saved-hover-scale"1.02"
savedTransitionDuration--saved-transition-duration"0.2s"

See the TypeScript SavedOpportunitiesThemingProps interface for the complete list.

Imperative Ref API

1import { useRef } from 'react'; 2import { LegionSavedOpportunities, LegionSavedOpportunitiesHandle } from '@legionhandtech/lht-react-widgets'; 3 4function App() { 5 const widgetRef = useRef<LegionSavedOpportunitiesHandle>(null); 6 7 return ( 8 <> 9 <button onClick={() => widgetRef.current?.refresh()}> 10 Refresh Saved Opportunities 11 </button> 12 <LegionSavedOpportunities 13 ref={widgetRef} 14 baseUrl="https://your-legion-domain.com" 15 authToken="your-jwt-token" 16 /> 17 </> 18 ); 19}
MethodDescription
refresh()Reloads the widget iframe

Web Component (from NPM)

import '@legionhandtech/lht-react-widgets/saved-opportunities-web-component';
1<legion-saved-opportunities 2 api-url="https://your-legion-domain.com" 3 auth-token="your-jwt-token" 4 theme="light"> 5</legion-saved-opportunities>

TypeScript

1import type { 2 SavedOpportunitiesWidgetProps, 3 SavedOpportunitiesThemingProps, 4 LegionSavedOpportunitiesHandle, 5} from '@legionhandtech/lht-react-widgets';

Callbacks

onLoad

1<LegionSavedOpportunities 2 baseUrl="https://your-legion-domain.com" 3 authToken="your-jwt-token" 4 onLoad={(detail) => { 5 console.log(detail.widget); // "saved-opportunities" 6 console.log(detail.theme); // "light" | "dark" 7 }} 8/>

onError

1<LegionSavedOpportunities 2 baseUrl="https://your-legion-domain.com" 3 onError={(message) => console.error(message)} 4/>
Documentation | Legion Hand Technologies