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

shaper-react

v0.6.1

Published

Embed [Shaper](https://taleshape.com) components in your React app

Readme

Shaper React Embedding SDK

Embed Shaper components in your React app

Usage

See the react router example app for a complete example app.

Installation

npm install shaper-react

Basic Example

import { ShaperDashboard } from "shaper-react";

// In your component

<ShaperDashboard
  baseUrl={"http://localhost:5454"}
  id={"your-dashboard-id"}
  jwt={jwt}
  refreshJwt={() => {
    fetchJwt();
  }}
/>

Props

// The ID of the dashboard to embed.
// Get this from the Shaper UI.
id: string;

// The base URL of the Shaper instance.
// Must be reachable from the user's browser.
baseUrl: string;

// JWT token for authentication.
// Dashboard can only load with a valid JWT.
// Dashboard is in loading state if jwt is undefined.
// This allows you to load the token asynchronously.
// Make sure you generate a token that matches the permissions of the logged in user.
jwt?: string;

// This function is called when the JWT token needs to be refreshed.
// It is also called initially if jwt prop is undefined.
// Use this as trigger to load the token and then set the jwt prop accordingly.
refreshJwt: () => void;

// Optional object of variables passed to the dashboard.
// Values must be strings or arrays of strings.
// Can be used in SQL via `getvariable()` function.
// Set this if you want to control the dashboard's variables from your app.
// This is useful if you like to store the dashboard state in the URL or local storage for example.
// Use this in combination with the onVarsChanged callback to update the vars as needed.
vars?: ShaperDashboardVars;

// Optional callback that is called when the dashboard's variables change.
// Also see vars prop.
onVarsChanged?: (newVars: ShaperDashboardVars) => void;

// Optional callback that is called when embed JS script cannot be loaded from the Shaper instance.
// Use this to render an error message or a fallback UI.
// By default an empty div is rendered.
onLoadError?: (error: string) => void;

// Optional className to be applied to the container div.
// Use this to customize the styling of the dashboard container.
className?: string;

Getting the JWT token

To authenticate with Shaper, your backend needs to call the Shaper API and get a JWT token.

  1. Create an API Key in the Shaper Admin UI and provide it as a secret to your backend. Never send this key to the client.
  2. When the refreshJwt callback is called, call your backend and get a new JWT token. By default, tokens are valid for 15 minutes. If a user is active for longer than that, Shaper will call refreshJwt again to request a new JWT token.
  3. Send a POST request to the /api/auth/token Shaper API endpoint. The request body must contain the following JSON data:
    • token: The API key you created in step 1.
    • dashboardId: The ID of the dashboard you want to embed.
    • variables: (optional) An object containing variables to pass to the dashboard. These variables cannot be overridden by the user. Use this to restrict what the user is able to see. For example, you can set a "user_id" or "organization_id" and use these as filters in your SQL queries.
  4. The API response looks like { "jwt": "..." }. Send the JWT token to the client and set as the jwt prop of the ShaperDashboard component.

Example Request

const r = await fetch(`${SHAPER_BASE_URL}/api/auth/token`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    token: API_KEY,
    dashboardId: dashboardId,
    variables: variables,
  }),
});