FundChart DocsTry with your fund

Docs/Embed on your site

Fund performance charts in React and Next.js

Using FundChart custom elements in React/Next.js apps, including SSR notes.

Updated 8 Nov 2026View as Markdown

What investors find today

A firm with its own developers usually has a React or Next.js site, and the fund page on it is still a PDF link or a table someone retypes each month. FundChart draws the live page instead: facts, returns against the benchmark, exposure, holdings, in the firm's colours and current to last month-end, from the factsheet or workbook the team already produces. In React it is three ordinary HTML tags and one script; nothing to install from npm.

Before you start

  • A FundChart workspace with the fund published. In the fund's review, open the Layout step, press Layout, open the Embed code card and Copy "Full fund page": it gives your token and the fund's id.
  • Your domains under Settings → API & agents → allowed domains, if you want the token to draw only on your sites. localhost works while none are listed.

React (Vite, Create React App, any client-side React)

Load the script once, from the component at the top of your app, and use the tags anywhere in your JSX. React 19 passes their attributes through as written.

import { useEffect } from 'react'

// Once for the whole app. The tags can render before or after the script arrives: it upgrades any already on the page.
function useFundChart() {
  useEffect(() => {
    if (document.querySelector('script[data-fundchart]')) return
    const s = document.createElement('script')
    s.src = 'https://embed.fundchart.io/e.js'
    s.async = true
    s.dataset.fundchart = ''
    document.body.appendChild(s)
  }, [])
}

export function FundsPage() {
  useFundChart()
  return <fundchart-center token="fcp_YOUR_TOKEN" link-template="/funds/{slug}"></fundchart-center>
}

export function FundPage({ fundId }: { fundId: string }) {
  useFundChart()
  return <fundchart-page token="fcp_YOUR_TOKEN" fund={fundId}></fundchart-page>
}
A React app's Funds page: the fund centre lists each fund with its returns and as-at date; each row links to the fund's route.
A React app's Funds page: the fund centre lists each fund with its returns and as-at date; each row links to the fund's route.

Route changes need nothing from you. When the router swaps one page for another, the new tags draw themselves; going back redraws the old ones. StrictMode's double effects are safe, the script loads once.

The same Funds page on a phone: each fund becomes a card.
The same Funds page on a phone: each fund becomes a card.
The fund's own route: the full fund page under the site's header.
The fund's own route: the full fund page under the site's header.

TypeScript

TypeScript does not know the three tags. Declare them once, in any .d.ts file the project includes:

import 'react'
type FundChartTag = { token: string; fund?: string; name?: string; type?: string; sections?: string; background?: string; 'link-template'?: string }
declare module 'react' {
  namespace JSX {
    interface IntrinsicElements {
      'fundchart-page': FundChartTag
      'fundchart-center': FundChartTag
      'fundchart-widget': FundChartTag
    }
  }
}

Next.js (App Router)

Put the script in the root layout with next/script and use the tags in server components; they need no 'use client'. The server sends the tags as plain HTML, the script loads after hydration and draws into them, and client-side navigation with <Link> works as in React.

// app/layout.tsx
import Script from 'next/script'

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script src="https://embed.fundchart.io/e.js" />
      </body>
    </html>
  )
}

// app/funds/[slug]/page.tsx
export default async function Fund({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params
  return <fundchart-page token="fcp_YOUR_TOKEN" fund={FUND_IDS[slug]} name={slug}></fundchart-page>
}

The fund centre's link-template="/funds/{slug}" makes each whole row a link to that route (a hash router takes #{slug} the same way), so a Funds page and one page per fund is two files.

One chart on its own

<fundchart-widget type="perf-chart" token fund> draws one section in a component of your own. Types: facts, hero, perf-chart, perf-table, growth, allocation, allocation-donut, exposure, exposure-donut, risk-return, holdings, monthly, disclaimer. A type the fund has no data for draws nothing.

Styling and layout

  • The embed draws inside its own shadow root: Tailwind, CSS modules and global styles do not reach into it, and its styles do not leak out.
  • It sizes to its parent's width. Put it in the content column and never give a parent a fixed height.
  • Look, brand colour, font and sections come from the layout saved in FundChart; an attribute on the tag overrides them for that tag. The full list is in the developer docs.

Raw data instead

To draw your own charts, read the figures as JSON from the API with a workspace API key (Settings → API & agents): GET https://api.fundchart.io/v1/funds and /v1/funds/{id}, described in the API docs. Published figures only, the same ones the embed shows; the disclaimer is yours to carry.

Month-end

Nothing to deploy. Upload next month's factsheet in FundChart, review, approve: the page on your site shows the new month within a minute.

If it does not show

  • Nothing at all: the script did not load. Check the network tab for e.js, and a content security policy: allow embed.fundchart.io and api.fundchart.io in script-src and connect-src.
  • A TypeScript error on the tag: add the declaration above.
  • "domain not allowed for this token": add the domain. A preview deployment needs its own host listed (my-site-git-branch.vercel.app), never the whole of vercel.app: an entry also allows every subdomain under it.
  • The phone layout on a desktop: the tag is in a narrow column.