Framework bindings
Lumen Ticks keeps framework adapters intentionally thin: each adapter creates the chart on mount, forwards option changes to applyOptions, and calls destroy() on unmount.
Data always goes through the ChartApi, never through reactive framework props. Passing millions of bars through component props would force unnecessary diffing and allocations on every tick.
Selecting a tab below also selects that framework across Getting started and every feature guide.
Basic setup & reactive options
Section titled “Basic setup & reactive options”Pass display configuration (such as theme, grid, crosshair, priceScales, or localization) through the wrapper’s options prop and load data through the ChartApi instance:
pnpm add @lumen-ticks/corenpm install @lumen-ticks/coreyarn add @lumen-ticks/corebun add @lumen-ticks/coreimport { createChart } from '@lumen-ticks/core';
const chart = createChart(document.getElementById('chart')!, { theme: 'dark' });const candles = chart.addSeries('candlestick', { id: 'BTCUSD' });candles.setData(bars);chart.timeScale().fitContent();
// Clean up when leaving the page or view:chart.destroy();pnpm add @lumen-ticks/react reactnpm install @lumen-ticks/react reactyarn add @lumen-ticks/react reactbun add @lumen-ticks/react reactLumenChart renders a <div> and exposes the ChartApi instance through a ref (null until mounted). Pass a state setter (ref={setChart}) when running useEffect against the chart so effects fire as soon as the instance is created — including across React StrictMode remounts.
import type { OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi } from '@lumen-ticks/react';import { useEffect, useMemo, useState } from 'react';
export function PriceChart({ dark, bars }: { dark: boolean; bars: OhlcColumns }) { const [chart, setChart] = useState<ChartApi | null>(null); const options = useMemo(() => ({ theme: dark ? ('dark' as const) : ('light' as const) }), [dark]);
useEffect(() => { if (chart === null) return; const candles = chart.addSeries('candlestick', { id: 'BTCUSD' }); candles.setData(bars); chart.timeScale().fitContent(); return () => chart.removeSeries(candles); }, [chart, bars]);
return <LumenChart ref={setChart} options={options} style={{ height: 420 }} />;}pnpm add @lumen-ticks/vue vuenpm install @lumen-ticks/vue vueyarn add @lumen-ticks/vue vuebun add @lumen-ticks/vue vueLumenChart exposes the ChartApi instance as chart on the template ref and deep-watches :options to forward updates to applyOptions.
<script setup lang="ts">import type { OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi } from '@lumen-ticks/vue';import { computed, onMounted, useTemplateRef } from 'vue';
const props = defineProps<{ dark: boolean; bars: OhlcColumns }>();const chartEl = useTemplateRef<{ chart: ChartApi | null }>('chartEl');const options = computed(() => ({ theme: props.dark ? ('dark' as const) : ('light' as const) }));
onMounted(() => { const chart = chartEl.value?.chart; if (!chart) return; const candles = chart.addSeries('candlestick', { id: 'BTCUSD' }); candles.setData(props.bars); chart.timeScale().fitContent();});</script>
<template> <LumenChart ref="chartEl" :options="options" style="height: 420px" /></template>pnpm add @lumen-ticks/svelte sveltenpm install @lumen-ticks/svelte svelteyarn add @lumen-ticks/svelte sveltebun add @lumen-ticks/svelte svelte@lumen-ticks/svelte exports the lumenChart action. Receive the ChartApi once in onReady; reactive reads inside options flow to applyOptions automatically.
<script lang="ts"> import type { OhlcColumns } from '@lumen-ticks/core'; import { lumenChart, type ChartApi } from '@lumen-ticks/svelte';
let { dark = false, bars }: { dark?: boolean; bars: OhlcColumns } = $props();
function onReady(chart: ChartApi) { const candles = chart.addSeries('candlestick', { id: 'BTCUSD' }); candles.setData(bars); chart.timeScale().fitContent(); }</script>
<div style="height: 420px" use:lumenChart={{ options: { theme: dark ? 'dark' : 'light' }, onReady }}></div>pnpm add @lumen-ticks/solid solid-jsnpm install @lumen-ticks/solid solid-jsyarn add @lumen-ticks/solid solid-jsbun add @lumen-ticks/solid solid-js@lumen-ticks/solid renders a client-side <div> and passes the ChartApi instance to onReady. Style the container through class.
import type { OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi } from '@lumen-ticks/solid';
export function PriceChart(props: { dark: boolean; bars: OhlcColumns }) { const handleReady = (chart: ChartApi) => { const candles = chart.addSeries('candlestick', { id: 'BTCUSD' }); candles.setData(props.bars); chart.timeScale().fitContent(); };
return <LumenChart class="chart-box" options={{ theme: props.dark ? 'dark' : 'light' }} onReady={handleReady} />;}Streaming live ticks & indicators
Section titled “Streaming live ticks & indicators”Keep the series handle outside component state and forward incoming ticks straight to candles.update(tick). Your UI framework never re-renders on price ticks, while the data engine updates the bar and every indicator incrementally in one atomic patch:
import { createChart, type OhlcBar, type OhlcColumns } from '@lumen-ticks/core';
const chart = createChart(document.getElementById('chart')!, { theme: 'auto' });const candles = chart.addSeries('candlestick', { id: 'BTCUSD' });candles.setData(history);candles.addIndicator('ema', { params: { period: 20 } });chart.timeScale().fitContent();
const stopStream = subscribeTicks('BTCUSD', (tick: OhlcBar) => { candles.update(tick);});
// Later on teardown:stopStream();chart.destroy();import type { OhlcBar, OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi } from '@lumen-ticks/react';import { useEffect, useState } from 'react';
const options = { theme: 'auto' as const };
export function LiveChart({ symbol, history }: { symbol: string; history: OhlcColumns }) { const [chart, setChart] = useState<ChartApi | null>(null);
useEffect(() => { if (chart === null) return; const candles = chart.addSeries('candlestick', { id: symbol }); candles.setData(history); candles.addIndicator('ema', { params: { period: 20 } }); chart.timeScale().fitContent();
const stopStream = subscribeTicks(symbol, (tick: OhlcBar) => { candles.update(tick); });
return () => { stopStream(); chart.removeSeries(candles); }; }, [chart, symbol, history]);
return <LumenChart ref={setChart} options={options} style={{ height: 420 }} />;}<script setup lang="ts">import type { OhlcBar, OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi } from '@lumen-ticks/vue';import { onBeforeUnmount, onMounted, useTemplateRef } from 'vue';
const props = defineProps<{ symbol: string; history: OhlcColumns }>();const chartEl = useTemplateRef<{ chart: ChartApi | null }>('chartEl');const options = { theme: 'auto' as const };let stopStream: (() => void) | undefined;
onMounted(() => { const chart = chartEl.value?.chart; if (!chart) return; const candles = chart.addSeries('candlestick', { id: props.symbol }); candles.setData(props.history); candles.addIndicator('ema', { params: { period: 20 } }); chart.timeScale().fitContent();
stopStream = subscribeTicks(props.symbol, (tick: OhlcBar) => { candles.update(tick); });});
onBeforeUnmount(() => stopStream?.());</script>
<template> <LumenChart ref="chartEl" :options="options" style="height: 420px" /></template><script lang="ts"> import type { OhlcBar, OhlcColumns } from '@lumen-ticks/core'; import { lumenChart, type ChartApi } from '@lumen-ticks/svelte'; import { onDestroy } from 'svelte';
let { symbol, history }: { symbol: string; history: OhlcColumns } = $props(); let stopStream: (() => void) | undefined;
function onReady(chart: ChartApi) { const candles = chart.addSeries('candlestick', { id: symbol }); candles.setData(history); candles.addIndicator('ema', { params: { period: 20 } }); chart.timeScale().fitContent();
stopStream = subscribeTicks(symbol, (tick: OhlcBar) => { candles.update(tick); }); }
onDestroy(() => stopStream?.());</script>
<div style="height: 420px" use:lumenChart={{ options: { theme: 'auto' }, onReady }}></div>import type { OhlcBar, OhlcColumns } from '@lumen-ticks/core';import { LumenChart, type ChartApi } from '@lumen-ticks/solid';import { onCleanup } from 'solid-js';
export function LiveChart(props: { symbol: string; history: OhlcColumns }) { const handleReady = (chart: ChartApi) => { const candles = chart.addSeries('candlestick', { id: props.symbol }); candles.setData(props.history); candles.addIndicator('ema', { params: { period: 20 } }); chart.timeScale().fitContent();
const stopStream = subscribeTicks(props.symbol, (tick: OhlcBar) => { candles.update(tick); }); onCleanup(stopStream); };
return <LumenChart class="chart-box" options={{ theme: 'auto' }} onReady={handleReady} />;}Subscribing to chart events
Section titled “Subscribing to chart events”Chart events such as crosshairMove, click, error, and timeScale().subscribe('visibleTimeRangeChange', ...) return an unsubscribe function. Wire them into reactive state to render custom legends, toolbars, or alerts:
import { createChart } from '@lumen-ticks/core';
const chart = createChart(document.getElementById('chart')!);const legend = document.getElementById('legend')!;
const unsubscribe = chart.subscribe('crosshairMove', event => { const bar = event.values.get('BTCUSD'); legend.textContent = bar && 'close' in bar ? `O ${bar.open.toFixed(2)} H ${bar.high.toFixed(2)} C ${bar.close.toFixed(2)}` : '';});
// Call unsubscribe() when no longer needed (or chart.destroy() removes all listeners).import { LumenChart, type ChartApi } from '@lumen-ticks/react';import { useEffect, useState } from 'react';
export function ChartWithLegend() { const [chart, setChart] = useState<ChartApi | null>(null); const [readout, setReadout] = useState('');
useEffect(() => { if (chart === null) return; return chart.subscribe('crosshairMove', event => { const bar = event.values.get('BTCUSD'); setReadout( bar && 'close' in bar ? `O ${bar.open.toFixed(2)} H ${bar.high.toFixed(2)} C ${bar.close.toFixed(2)}` : '', ); }); }, [chart]);
return ( <> <output>{readout}</output> <LumenChart ref={setChart} style={{ height: 420 }} /> </> );}<script setup lang="ts">import { LumenChart, type ChartApi } from '@lumen-ticks/vue';import { onBeforeUnmount, onMounted, ref, useTemplateRef } from 'vue';
const chartEl = useTemplateRef<{ chart: ChartApi | null }>('chartEl');const readout = ref('');let unsubscribe: (() => void) | undefined;
onMounted(() => { const chart = chartEl.value?.chart; if (!chart) return; unsubscribe = chart.subscribe('crosshairMove', event => { const bar = event.values.get('BTCUSD'); readout.value = bar && 'close' in bar ? `O ${bar.open.toFixed(2)} H ${bar.high.toFixed(2)} C ${bar.close.toFixed(2)}` : ''; });});
onBeforeUnmount(() => unsubscribe?.());</script>
<template> <output>{{ readout }}</output> <LumenChart ref="chartEl" style="height: 420px" /></template><script lang="ts"> import { lumenChart, type ChartApi } from '@lumen-ticks/svelte'; import { onDestroy } from 'svelte';
let readout = $state(''); let unsubscribe: (() => void) | undefined;
function onReady(chart: ChartApi) { unsubscribe = chart.subscribe('crosshairMove', event => { const bar = event.values.get('BTCUSD'); readout = bar && 'close' in bar ? `O ${bar.open.toFixed(2)} H ${bar.high.toFixed(2)} C ${bar.close.toFixed(2)}` : ''; }); }
onDestroy(() => unsubscribe?.());</script>
<output>{readout}</output><div style="height: 420px" use:lumenChart={{ onReady }}></div>import { LumenChart, type ChartApi } from '@lumen-ticks/solid';import { createSignal, onCleanup } from 'solid-js';
export function ChartWithLegend() { const [readout, setReadout] = createSignal('');
const handleReady = (chart: ChartApi) => { const unsubscribe = chart.subscribe('crosshairMove', event => { const bar = event.values.get('BTCUSD'); setReadout( bar && 'close' in bar ? `O ${bar.open.toFixed(2)} H ${bar.high.toFixed(2)} C ${bar.close.toFixed(2)}` : '', ); }); onCleanup(unsubscribe); };
return ( <> <output>{readout()}</output> <LumenChart class="chart-box" onReady={handleReady} /> </> );}Package summary
Section titled “Package summary”| Package | Export | Props / params | Chart access | Lifecycle |
|---|---|---|---|---|
@lumen-ticks/core |
createChart |
(container, options?) |
Returned ChartApi |
Manual destroy() |
@lumen-ticks/core |
createChart |
(container, options?) |
Returned ChartApi |
Manual destroy() |
@lumen-ticks/react |
LumenChart |
options?, className?, style? |
ref (ChartApi | null) |
useEffect mount / unmount (StrictMode) |
@lumen-ticks/vue |
LumenChart |
options? (plus fallthrough attrs) |
Template ref { chart: ChartApi | null } |
onMounted / onBeforeUnmount |
@lumen-ticks/svelte |
lumenChart |
{ options?, onReady? } |
onReady(chart) callback |
Svelte action update / destroy |
@lumen-ticks/solid |
LumenChart |
options?, class?, onReady? |
onReady(chart) callback |
onMount / onCleanup (client-side only) |
Every framework package also re-exports ChartApi, ChartOptions, DeepPartial, the worker configuration helpers (configureWorker, createWorkerPool, getWorkerConfig, setMaxWorkers, getMaxWorkers), and a standalone ./worker subpath entry. Lower-level types such as PanePrimitive or OhlcColumns can be imported from @lumen-ticks/core (or lumen-ticks).
Adapter tips & SSR
Section titled “Adapter tips & SSR”- Server-side rendering (SSR): Canvases and
ResizeObserverrun in the browser. Mark React components with'use client'in Next.js App Router, wrap Vue charts in<ClientOnly>in Nuxt, mount Svelte actions on the client in SvelteKit (Svelte actions only execute in the browser), and wrap@lumen-ticks/solidwithclientOnly()in SolidStart because it callsdocument.createElement('div')during component setup. - Sizing: Give the chart element an explicit CSS height (
style={{ height: 420 }},style="height: 420px", or a CSS class withheightfor Solid).autoSizeis enabled by default and shares oneResizeObserveracross all charts on the page.