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

@embeddables/core

v0.7.3

Published

Core Embeddables identity and configuration SDK for client and server.

Readme

@embeddables/core

Install

npm install @embeddables/core

Usage

Client Example:

import { initEmbeddables } from '@embeddables/core'
import { config } from './embeddables/_dist/config.ts'

const embeddables = initEmbeddables({ ...config })

embeddables.getAppUserId()
embeddables.getProjectId()
embeddables.getPublishableKey() // string | undefined

Persist and restore the last visited dynamic page key (browser-only):

await embeddables.registerPageView({ pageKey: 'checkout' })
const lastPage = embeddables.getLastPageView() // 'checkout' after reload + re-init

Optionally emit a page:viewed analytics event when Analytics is wired post-init:

import { initAnalytics } from '@embeddables/analytics'

const embeddables = initEmbeddables({ ...config })
const analytics = initAnalytics({ core: embeddables, publishableKey: 'pk_live_…' })
embeddables.setAnalyticsInstance(analytics)
await embeddables.registerPageView({ pageKey: 'checkout' })

In React, pass analytics() in EmbeddablesProvider's modules prop — the module wires setAnalyticsInstance during init. See React below.

Server Example:

import { initEmbeddablesServer } from '@embeddables/core/server'
import { config } from './embeddables/_dist/config.ts'

const embeddables = initEmbeddablesServer({
  ...config,
  cookies: {
    get(key) {
      return readCookie(key)
    },
  },
})

publishableKey is optional. Pass it on config when using an SDK that requires authentication, such as @embeddables/analytics. Core initializes successfully without it.

App authentication

Each instance owns one app-level auth manager:

const core = initEmbeddables({
  ...config,
  publishableKey: 'pk_live_…',
})

await core.auth.requestOtp({ phone: '+15551234567' })
await core.auth.verifyOtp({ phone: '+15551234567', token: '123456' })
await core.auth.refresh()
await core.auth.logout()

React

Install React alongside Core:

npm install @embeddables/core react

Place EmbeddablesProvider above every Embeddables product binding. Pass product SDK modules through the modules prop and each product's configuration through the prop named after it. The provider initializes every module before publishing Core as ready, so a component that sees Core as ready always sees every product client already registered.

Example:

import {
  EmbeddablesProvider,
  useAppUserId,
  useEmbeddables,
  useEmbeddablesProjectId,
} from '@embeddables/core/react'
import { config } from './embeddables/_dist/config.ts'
import { modules as generatedModules } from './embeddables/_dist/modules.ts'

function App() {
  return (
    <EmbeddablesProvider
      config={config}
      publishableKey={import.meta.env.VITE_EMBEDDABLES_PUBLISHABLE_KEY}
      modules={generatedModules}
    >
      <Identity />
    </EmbeddablesProvider>
  )
}

function Identity() {
  const embeddables = useEmbeddables()
  const appUserId = useAppUserId()
  const projectId = useEmbeddablesProjectId()

  if (embeddables?.isError) return <p>Embeddables could not initialize.</p>
  if (embeddables == null) return <p>Loading…</p>
  return (
    <p>
      {projectId}: {appUserId}
    </p>
  )
}

Page views

useRegisterPageView() records a page view against the ambient instance. The last page key is always written to storage; the page:viewed event only goes out when the analytics() module registered a client on the same provider. It never throws — an invalid page key or an unwritable store comes back as isError.

import { useEffect } from 'react'
import { useEmbeddables, useRegisterPageView } from '@embeddables/core/react'

function Step({ pageKey }: { pageKey: string }) {
  const embeddables = useEmbeddables()
  const { registerPageView, getLastPageView, isError } = useRegisterPageView()

  // * React runs child effects before parent effects, so gate on Core being
  // * ready — otherwise the very first page view no-ops and is dropped.
  useEffect(() => {
    if (embeddables == null || embeddables.isError) return
    void registerPageView({ pageKey, isFunnelStep: true, funnelStepLabel: 'Checkout' })
  }, [embeddables, registerPageView, pageKey])

  return <p>previous: {getLastPageView() ?? 'none'}</p>
}

Example (manual module list):

import { analytics } from '@embeddables/analytics/react'

<EmbeddablesProvider config={config} publishableKey="pk_live_…" modules={[analytics()]}>
  {children}
</EmbeddablesProvider>
  • modules is optional, and its order does not matter — the provider works out which modules depend on which and initializes them accordingly.
  • Configure a product through the top-level prop named after it (analytics, forms, protocols, …). Each module only ever sees its own value, and configuring a product that is not in modules is an error rather than a silent no-op.
  • publishableKey overrides config.publishableKey for this provider instance.
  • excludeAnalyticsInModules turns off automatic Analytics tracking for the named modules.
  • CLI build generates embeddables/_dist/modules.ts from enabledModules in config.yaml.
  • useEmbeddables() returns null during server rendering, the first client render, and until initialization completes. On failure it returns { isError: true, error, appUserId: null }.
  • useAppUserId() and useEmbeddablesProjectId() return null until Core is ready inside EmbeddablesProvider.
  • Pass serverAppUserId to the provider when the server has already resolved the identity.

The provider treats its initial configuration, modules, product parameters, and identity as immutable. Remount it to initialize a different project or identity.