Skip to main content

Framework and Widget Starters

The Quickstart chart binds cleanly to any component lifecycle: your framework owns create and destroy in one place, and the SDK owns everything between them. The same binding carries the standalone widgets — market depth, time and sales, watchlist, order ticket, and the full trading terminal.

Complete the shared prerequisites once, then open your framework's tab. Every tab assumes them.

Shared prerequisites

  1. Complete Package access, install the private SDK under the @tradescript/pro alias, and import its styles once at the application entry point:
npm install --save-exact '@tradescript/pro@npm:@tradescript/charts-pro-acme-production-a1b2c@0.1.1'
import '@tradescript/pro/style.css';
import '@tradescript/pro/tailwind.css';
  1. Export a stable MarketDataFeed as datafeed from a datafeed module. Implement loadBars first, then add search, realtime, quotes, depth, news, or trading capabilities as your product needs them. See Datafeeds for the contract.

  2. Give the mount element a real height. A zero-height container renders nothing.

  3. Every direct-mount starter calls destroy() when its framework unmounts the component so chart DOM, workers, and market-data subscriptions are released together. The optional React component performs that teardown when it unmounts.

Production builds

The lifecycle examples below import deploymentLease from application bootstrap. That value is the backend-cached shared lease, never the permanent API credential. createTradeScriptSdk({ lease }) verifies it before the first product surface mounts and returns the authorization-bound TradeScriptSdk; see Customer authorization.

Pick your framework

Use the core lifecycle directly in a browser application or any frontend framework that gives you an HTML element.

src/chart.ts
import { createTradeScriptSdk } from '@tradescript/pro/sdk/core';
import { datafeed } from './datafeed';
import '@tradescript/pro/style.css';
import '@tradescript/pro/tailwind.css';

declare const deploymentLease: string;

const sdk = await createTradeScriptSdk({ lease: deploymentLease });
const mounted = sdk.chart.mount({
mount: '#chart',
symbol: { ticker: 'AAPL', exchange: 'NASDAQ', type: 'stock' },
interval: '15m',
datafeed,
theme: 'dark',
});

const widget = await mounted.ready();
await widget.chart().dataReady();

// Call this when the page, route, or owning view is removed.
export function destroyChart() {
mounted.destroy();
}
<div id="chart" style="height: 640px"></div>

Mount standalone widgets in any framework

The authorized SDK exposes every embeddable product surface through a named framework-neutral module. You provide a DOM element and typed props; the returned owner can update the mounted surface and destroy it when the route or component unmounts.

ExperienceModuleProduct guide
Desktop chart or multi-chart workspacesdk.chartChart widget
Touch-first chartsdk.mobileChartMobile chart
Market depth and trade tapesdk.marketDepth, sdk.timeAndSalesOrder flow
Watchlist and session statussdk.watchlist, sdk.sessionMetaWatchlist, Session info
Account and order entrysdk.accountPanel, sdk.accountSummary, sdk.orderTicket, sdk.orderTicketLauncherTrading
Options and price laddersdk.optionChain, sdk.optionOrderTicket, sdk.ladderOption order ticket
Complete terminal or composable layoutsdk.tradingTerminal, sdk.layoutTrading, Multi-chart workspace
Agent activity consolesdk.agentConsoleAgents and MCP

For example, mount a chart and a market-depth panel into two framework-owned elements:

const chartMount = sdk.chart.mount({
mount: '#chart',
symbol: 'AAPL',
interval: '15m',
datafeed,
});

const widget = await chartMount.ready();
const depthMount = sdk.marketDepth.mount({
mount: '#depth',
controller: widget.data(),
symbol: widget.chart().getSymbol(),
levels: 20,
theme: 'dark',
});

// A later framework state change updates the existing panel.
depthMount.update({ levels: 50 });

// Run both when the owning route or component unmounts.
depthMount.destroy();
chartMount.destroy();

Use the same teardown point your framework already provides:

  • React or Next.js: the useEffect cleanup function.
  • Vue or Nuxt: onBeforeUnmount.
  • Svelte: the function returned from onMount.
  • Angular: ngOnDestroy.
  • Plain JavaScript: the router/view disposal callback.

React and Next.js can choose either these named mounts or the exported React components. Angular, Vue, Nuxt, Svelte, and plain JavaScript do not need a React wrapper: use the named SDK modules directly. For complete standalone-widget lifecycle examples, see Standalone Widgets by Framework.

Verify the chart

The same checkpoint applies to every framework:

  1. Load the route that renders the starter component. You should see the chart toolbar, price scale, and a candlestick series for AAPL at 15m once loadBars returns.
  2. Navigate away from the route. The component's teardown runs destroy(); no chart DOM, worker, or subscription should remain (no continued network activity from the feed).
  3. Navigate back. A fresh widget mounts cleanly.

Common failure modes

  • Empty container: the mount element has no real height — every starter sets an explicit height for this reason.
  • Chart created twice or leaks on route change: the framework unmounted before createTradeScriptSdk({ lease }) resolved — the Svelte and Next.js starters guard this with a disposed flag; keep that pattern when an async bootstrap can outlive the component.
  • SSR error such as document is not defined: the chart was constructed during server rendering — use the client-only patterns shown in the Angular, Next.js, and Nuxt tabs.
  • Unstyled chart: SDK styles must be registered globally (Angular styles.css, Next.js root layout, Nuxt nuxt.config.ts), not inside a scoped component stylesheet.

Try the same API live

Open the hosted playground to change the symbol, interval, and theme against a live feed and copy the resulting core mount() snippet.

Next steps