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

@eikonstudio/variant

v0.1.0

Published

React-friendly helpers for switching between full landing page variants

Downloads

22

Readme

@eikonstudio/variant

React-friendly helpers for switching between multiple landing page variants.

@eikonstudio/variant is built for the case where one website has multiple full landing-page designs and the user can choose which one they prefer from a toggle or switcher UI. The selected variant is persisted, and the whole landing experience can swap seamlessly through one active variant state.

Install

bun add @eikonstudio/variant

react is a peer dependency, so install it in your app if it is not already present.

What this package gives you

  • createLandingRegistry() to define the available landing variants
  • LandingPreferenceProvider to manage the active variant in React
  • useLandingPreference() and useSetLandingPreference() hooks
  • LandingVariantToggle for a minimal unstyled toggle UI
  • LandingVariantRenderer for swapping the whole landing-page component
  • getStoredVariant() / setStoredVariant() helpers for persistence

Quick Start

import {
  createLandingRegistry,
  LandingPreferenceProvider,
  LandingVariantRenderer,
  LandingVariantToggle,
  type LandingRenderableVariant,
} from "@eikonstudio/variant";

function MinimalLanding({ headline }: { headline: string }) {
  return <section>{headline} Minimal landing</section>;
}

function BoldLanding({ headline }: { headline: string }) {
  return <section>{headline} Bold landing</section>;
}

const registry = createLandingRegistry([
  {
    id: "minimal",
    label: "Minimal",
    description: "Clean and simple",
    component: MinimalLanding,
  },
  {
    id: "bold",
    label: "Bold",
    description: "High contrast and punchy",
    component: BoldLanding,
  },
] as const satisfies readonly [
  LandingRenderableVariant<{ headline: string }>,
  LandingRenderableVariant<{ headline: string }>,
]);

export function LandingPage() {
  return (
    <LandingPreferenceProvider registry={registry} initialVariantId="minimal">
      <LandingVariantToggle />
      <LandingVariantRenderer componentProps={{ headline: "Welcome" }} />
    </LandingPreferenceProvider>
  );
}

How it works

  1. Create a registry with 2 or more variants.
  2. Wrap your landing page area in LandingPreferenceProvider.
  3. Render LandingVariantToggle so the user can choose a design.
  4. Render LandingVariantRenderer to swap the full active landing component.
  5. The selected variant id is saved to localStorage by default.

Full-page variant switching

Use LandingVariantRenderer when each variant represents a different complete landing-page design:

const registry = createLandingRegistry([
  { id: "classic", label: "Classic", component: ClassicLanding },
  { id: "modern", label: "Modern", component: ModernLanding },
  { id: "editorial", label: "Editorial", component: EditorialLanding },
] as const);

export function MarketingSite() {
  return (
    <LandingPreferenceProvider registry={registry}>
      <header>
        <h1>Choose your preferred design</h1>
        <LandingVariantToggle />
      </header>

      <main>
        <LandingVariantRenderer componentProps={{}} />
      </main>
    </LandingPreferenceProvider>
  );
}

When the active variant changes, the rendered landing component changes with it.

Hooks

useLandingPreference()

Use this when you want full access to the active variant, the full variant list, and the setter:

import { useLandingPreference } from "@eikonstudio/variant";

function VariantBadge() {
  const { activeVariant, variants, setVariant } = useLandingPreference();

  return (
    <div>
      <p>Current: {activeVariant.label}</p>
      {variants.map((variant) => (
        <button key={variant.id} onClick={() => setVariant(variant.id)}>
          {variant.label}
        </button>
      ))}
    </div>
  );
}

useSetLandingPreference()

Use this when you only need to change the variant:

import { useSetLandingPreference } from "@eikonstudio/variant";

function ChooseBoldButton() {
  const setVariant = useSetLandingPreference<{
    id: "minimal" | "bold";
    label: string;
  }>();

  return <button onClick={() => setVariant("bold")}>Use bold design</button>;
}

Persistence

By default, the package uses:

  • storage key: eikonstudio.variant.preference
  • storage adapter: browser localStorage when available

You can override both:

<LandingPreferenceProvider
  registry={registry}
  storageKey="my-site.landing-variant"
  storage={window.localStorage}
>
  <LandingVariantRenderer componentProps={{}} />
</LandingPreferenceProvider>

You can also use the low-level storage helpers directly:

import {
  clearStoredVariant,
  getStoredVariant,
  setStoredVariant,
} from "@eikonstudio/variant";

const current = getStoredVariant({ registry });
setStoredVariant("modern", { registry });
clearStoredVariant({});

SSR behavior

The package is SSR-safe:

  • it does not read window during module evaluation
  • it uses initialVariantId or the registry default during the initial render
  • it upgrades to the persisted client-side value after mount when one exists

That makes it suitable for React apps that render on the server and then hydrate on the client.

Development

cd packages/variant
bun run test
bun run lint
bun run build

License

MIT