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

@codatum/embed-react

v1.0.0

Published

React integration for Codatum signed embedding

Readme

@codatum/embed-react

React integration for Codatum Signed Embed. Provides a single component that wraps the core SDK. All of @codatum/embed is re-exported so you can use this package as a single entry point (one version, no split).

For options, types, events, and programmatic API details, see @codatum/embed.

Installation

pnpm add @codatum/embed-react
# or
npm install @codatum/embed-react

Requires React 18+ (peer dependency).

Usage

import { EmbedReact } from "@codatum/embed-react";

const embedUrl = "https://app.codatum.com/protected/workspace/xxx/notebook/yyy";
const tokenProvider = async () => {
  const res = await fetch("/api/embed-token", { method: "POST" });
  const data = await res.json();
  return { token: data.token };
};

function App() {
  return (
    <EmbedReact
      embedUrl={embedUrl}
      tokenProvider={tokenProvider}
      iframeOptions={{ theme: "LIGHT", locale: "ja" }}
      onStatusChanged={(e) => console.log("Status", e.status)}
      onParamChanged={(e) => console.log("Params", e.params)}
      onExecuteSqlsTriggered={(e) => console.log("Execute", e.params)}
      onError={(e) => console.error(e)}
    />
  );
}

Calling reload from the parent

Use a ref and call the exposed reload() method. It returns true on success and false on failure (errors are reported via onError; it does not throw).

import { useRef } from "react";
import { EmbedReact, type EmbedReactRef } from "@codatum/embed-react";

function App() {
  const embedRef = useRef<EmbedReactRef>(null);

  async function onFilterChange() {
    const ok = await embedRef.current?.reload();
    if (!ok) console.warn("reload failed — see onError");
  }

  return (
    <>
      <button type="button" onClick={onFilterChange}>
        Reload
      </button>
      <EmbedReact
        ref={embedRef}
        embedUrl="..."
        tokenProvider={...}
        onError={handleError}
      />
    </>
  );
}

Custom loading UI

Use renderLoading to show custom UI while loading. showLoadingOn controls which statuses show it (default: INITIALIZING / RELOADING / REFRESHING).

<EmbedReact
  embedUrl={embedUrl}
  tokenProvider={tokenProvider}
  renderLoading={() => <MySpinner />}
/>

Show only on first load:

<EmbedReact
  embedUrl={embedUrl}
  tokenProvider={tokenProvider}
  showLoadingOn={["INITIALIZING"]}
  renderLoading={() => <FullPageLoader />}
/>

Branch by status:

<EmbedReact
  embedUrl={embedUrl}
  tokenProvider={tokenProvider}
  renderLoading={({ status }) =>
    status === "INITIALIZING" ? <FullPageLoader /> : <SubtleBar />
  }
/>

Changing props at runtime

Props are read once at mount. To apply new values (e.g. a different embedUrl or iframeOptions), use key to force a remount:

<EmbedReact key={embedUrl} embedUrl={embedUrl} tokenProvider={tokenProvider} />

API

Option types and behavior (e.g. iframeOptions, tokenOptions, displayOptions, devOptions) are the same as in @codatum/embed. The component uses its root element as the iframe container (no container prop).

Props

| Prop | Required | Type | |------|----------|------| | embedUrl | Yes | string | | tokenProvider | Yes | (context: TokenProviderContext) => Promise<TokenProviderResult> | | iframeOptions | No | IframeOptions | | tokenOptions | No | TokenOptions | | displayOptions | No | DisplayOptions | | devOptions | No | DevOptions | | showLoadingOn | No | EmbedStatus[] — Which statuses show the loading overlay. Default: ['INITIALIZING', 'RELOADING', 'REFRESHING']. Ignored when renderLoading is not set. | | renderLoading | No | (props: { status: EmbedStatus }) => ReactNode — Custom UI shown while loading. When not set, the iframe's built-in loading is used. |

Callbacks

| Callback | Payload | When | |----------|---------|------| | onStatusChanged | (payload: { type: 'STATUS_CHANGED', status: EmbedStatus, previousStatus: EmbedStatus }) => void | See core SDK | | onParamChanged | (payload: { type: 'PARAM_CHANGED', params: EncodedParam[] }) => void | See core SDK | | onExecuteSqlsTriggered | (payload: { type: 'EXECUTE_SQLS_TRIGGERED', params: EncodedParam[] }) => void | See core SDK | | onExecutionSucceeded | (payload: { type: 'EXECUTION_SUCCEEDED' }) => void | See core SDK | | onExecutionFailed | (payload: { type: 'EXECUTION_FAILED', errorMessage: string }) => void | See core SDK | | onError | (err: EmbedError) => void | Init, reload, or token auto-refresh failed |

Ref (EmbedReactRef)

| Property | Type | Description | |----------|------|-------------| | reload() | () => Promise<boolean> | Re-fetches token and params; returns false on failure (error reported via onError) | | status | 'CREATED' \| 'INITIALIZING' \| 'RELOADING' \| 'REFRESHING' \| 'READY' \| 'DESTROYED' | Current embed state |

Need a custom container or full control? Use createEmbed() from this package (or @codatum/embed) inside a useEffect and call instance.destroy() in the cleanup.

See also