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

portals-sdk

v0.3.2

Published

End-user JavaScript/TypeScript client for the Embeddables v1 API.

Readme

portals-sdk

End-user JavaScript/TypeScript client for the Embeddables portals public API (/portals/v1/public/*). Portal apps use Core authentication re-exposed as client.auth and use this package to read profiles, manage usage and symptom logs, read Shopify order mirror data, and create outbound messages — without importing internal Embeddables workspace packages.

For AI agents: how to change the package in docs/sdk/portals-sdk.md (rules shared across every SDK in docs/sdk/sdk.md); routing in AGENTS.md. This file is for human/npm consumers.

Install

pnpm add portals-sdk @embeddables/core @sentry/react
# or
npm install portals-sdk @embeddables/core @sentry/react

Peer (install alongside this package): @sentry/react. hono and zod ship as dependencies.

Quick start (live)

import { initEmbeddables } from '@embeddables/core'
import { initPortals } from 'portals-sdk'

const core = initEmbeddables({
  projectId: '…',
  forms: [],
  experiments: [],
  publishableKey: 'pk_live_…', // from admin-web-app-worker → Settings → Portal / SDK
})

const client = initPortals(core)

await client.auth.requestOtp({ phone: '+15551234567' })
// complete OTP in your UI, then:
await client.auth.verifyOtp({ phone: '+15551234567', token: '123456' })

const profile = await client.profile.get()
await client.messages.create({ text: 'Hello from the portal' })
const orders = await client.orders.list() // Shopify mirror + trackings[]

For sandbox provisioning, configure auth.sandboxUser on initEmbeddables. Authentication is available through client.auth.

Mock mode (local UI dev)

Pass mock in portals options to run fully offline — no Embeddables backend required. Core does not need a publishable key in mock mode:

import { initEmbeddables } from '@embeddables/core'
import { initPortals, defineMockPersona } from 'portals-sdk'

const core = initEmbeddables({
  projectId: '…',
  forms: [],
  experiments: [],
})

const persona = defineMockPersona({
  id: 'active-streak',
  label: 'Active Streak',
  // … fixtures: profile, messages, usageLogs, shopifyOrders, etc.
})

const client = initPortals(core, {
  mock: { personas: [persona], initialPersonaId: persona.id },
})

Optional devtools bar (persona switcher, virtual date/time):

import { mountPortalsMockDevBar } from 'portals-sdk/devtools'

if (import.meta.env.DEV) {
  mountPortalsMockDevBar(client)
}

Monitoring (optional)

import { initSentryMonitoring } from 'portals-sdk/monitoring'

await initSentryMonitoring({
  dsn: import.meta.env.VITE_SENTRY_DSN,
  environment: 'production',
  portal: 'my-brand-portal',
})

Events go to the portals-sdk Sentry project. See root README.md for DSN and trace propagation setup.

Build from source (monorepo)

The SDK uses Hono RPC typing: client.ts imports PortalsPublicAppType from backend-worker at build time so client methods stay in sync with portal routes without hand-written response types. That is a dev-only workspace dependency — tsdown inlines resolved types into published .d.ts, so npm consumers never install backend-worker.

Build order (each package emits dist/*.d.ts for the next):

pnpm --filter @embeddables/core build
pnpm --filter @embeddables/shared-types build
pnpm --filter backend-worker build
pnpm --filter portals-sdk build

Published artifacts are ESM + CJS + .d.ts under dist/.

Slim PortalsPublicAppType-only type extraction is deferred unless compile time becomes a measured problem.

Local API override

Set at consumer build time (Vite VITE_*):

| Variable | Purpose | | ---------------------- | ------------------ | | VITE_PORTALS_API_URL | Backend API origin |

Defaults target production; unset vars work when core supplies a publishable key for live mode. A Dev or local host needs the same origin on both clients: initEmbeddables({ baseUrl }) and initPortals(core, { baseUrl }). Omitting baseUrl still honors VITE_PORTALS_API_URL for Portal requests only.