npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-apexstock

v0.2.1

Published

React component wrapper for ApexStock (financial charting on top of ApexCharts)

Readme

react-apexstock

React component wrapper for ApexStock — financial charting (candlesticks, indicators, drawing tools) built on top of ApexCharts.

It's a thin, typed wrapper around the imperative ApexStock class: it creates the instance on mount, forwards prop changes to update(), and tears it down on unmount.

Install

npm install react-apexstock apexstock apexcharts

apexcharts, apexstock, react, and react-dom are peer dependencies. ApexCharts must be available as a global (it's loaded the same way the core library expects). See the ApexStock docs for details.

Usage

import { useMemo } from "react";
import ApexStock from "react-apexstock";

export function PriceChart({ data }) {
  // Memoize so the chart only updates when inputs actually change.
  const options = useMemo(
    () => ({
      chart: { height: 420 },
      theme: { mode: "light" },
    }),
    []
  );
  const series = useMemo(() => [{ name: "Price", data }], [data]);

  return <ApexStock options={options} series={series} style={{ width: "100%" }} />;
}

OHLC points use the ApexStock shape { x, y: [open, high, low, close], v }.

Props

| Prop | Type | Description | | --- | --- | --- | | options | StockChartOptions | Full chart options (the 2nd arg to new ApexStock). Required. | | series | StockChartOptions["series"] | Convenience: overrides options.series (handy for frequently-changing data). | | className | string | Class on the container element. | | style | React.CSSProperties | Inline styles on the container element. |

Pass stable/memoized options and series — a new object identity on every render triggers an update().

Imperative ref

import { useRef } from "react";
import ApexStock, { type ApexStockRef } from "react-apexstock";

function Toolbar() {
  const ref = useRef<ApexStockRef>(null);
  const addRSI = () => ref.current?.getInstance()?.updateIndicator("rsi");
  return (
    <>
      <button onClick={addRSI}>Add RSI</button>
      <ApexStock ref={ref} options={{ chart: { height: 400 }, series }} />
    </>
  );
}
  • getInstance() → the live ApexStock instance (call any of its methods: update, updateIndicator, updateTheme, export, …), or null before mount.
  • getElement() → the container <div>.

Live demo

A no-build demo lives in demo/: the real wrapper driving the real ApexStock core (the unit tests mock the core, this does not). It loads React/ReactDOM from this package's node_modules via small ESM shims, and the core from the repo's dist/, so build both first and serve over a static server (no bundler needed):

npm install                  # in this package, for the React UMD builds
npm run build                # build the wrapper -> dist/
(cd ../.. && npm run build)  # build the core -> dist/

# Serve from the apexcharts working dir (parent of this repo) so the sibling
# apexcharts-js checkout also resolves, then open the demo URL:
cd ../../.. && python3 -m http.server 8080
# http://localhost:8080/apexstock/packages/react-apexstock/demo/

SSR

The component renders only a container <div> on the server; the chart is created in a client-only effect. (The core apexstock package is import-safe in Node, but rendering needs a DOM.)