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

@betaversionio/portfolio-sdk

v0.1.0

Published

SDK for fetching BetaVersion.io portfolio data. Framework-agnostic — works with Next.js, Remix, Astro, Vite, or any environment with global fetch.

Readme

@betaversionio/portfolio-sdk

SDK for fetching portfolio data from the BetaVersion.io API. Framework-agnostic — works with Next.js, Remix, Astro, Vite, or any environment that provides a global fetch.

Installation

npm install @betaversionio/portfolio-sdk

Quick start

import { BetaVersionClient } from '@betaversionio/portfolio-sdk';

const client = new BetaVersionClient();

const portfolio = await client.getPortfolio('johndoe');

if (portfolio) {
  console.log(portfolio.user.name);
  console.log(portfolio.projects);
  console.log(portfolio.blogs);
}

Resolving the username

The SDK provides a resolveUsername() helper that works across frameworks. It checks three sources in order:

  1. x-portfolio-username request header (SSR)
  2. PORTFOLIO_USERNAME environment variable
  3. <meta name="portfolio-username"> tag in the DOM (SPA)

Next.js / Remix / Astro (SSR)

Pass the incoming Request object:

import { resolveUsername } from '@betaversionio/portfolio-sdk';

// Next.js App Router
import { headers } from 'next/headers';

export async function getUsername() {
  const hdrs = await headers();
  return resolveUsername({
    request: new Request('http://localhost', { headers: hdrs }),
  });
}

// Remix loader
export async function loader({ request }: LoaderFunctionArgs) {
  const username = resolveUsername({ request });
  // ...
}

// Astro
const username = resolveUsername({ request: Astro.request });

Vite / SPA

Add a meta tag to your index.html (the proxy can inject this):

<meta name="portfolio-username" content="johndoe" />

Then call resolveUsername() with no arguments:

import { resolveUsername } from '@betaversionio/portfolio-sdk';

const username = resolveUsername();

Custom options

resolveUsername({
  envVar: 'MY_CUSTOM_ENV_VAR',    // override env var name
  metaTag: 'my-custom-meta-name', // override meta tag name
});

API

new BetaVersionClient(options?)

| Option | Type | Default | Description | | -------- | -------- | ---------------------------------- | ----------------- | | apiUrl | string | https://api.betaversion.io/v1 | Base API URL |

Methods

Every method accepts an optional fetchOptions parameter (RequestInit) that gets forwarded to the underlying fetch call. This lets you pass framework-specific options like Next.js revalidation:

await client.getPortfolio('johndoe', { next: { revalidate: 300 } });

client.getPortfolio(username, fetchOptions?)

Returns all portfolio data for a user, or null if the user is not found.

const data: PortfolioData | null = await client.getPortfolio('johndoe');

The returned PortfolioData includes:

| Field | Type | | -------------- | ------------------------ | | user | PortfolioUser | | projects | PortfolioProject[] | | blogs | PortfolioBlog[] | | resume | PortfolioResume \| null| | followCounts | FollowCounts |

client.getProject(slug, fetchOptions?)

Returns a single project by slug, or null if not found.

const project: PortfolioProject | null = await client.getProject('my-project');

client.getBlog(slug, fetchOptions?)

Returns a single blog post by slug, or null if not found.

const blog: PortfolioBlog | null = await client.getBlog('my-post');

Types

All types are exported from the package:

import type {
  PortfolioUser,
  PortfolioProject,
  PortfolioBlog,
  PortfolioResume,
  FollowCounts,
  PortfolioData,
  BetaVersionClientOptions,
  ResolveUsernameOptions,
} from '@betaversionio/portfolio-sdk';

License

MIT