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

ls-client-sdk

v1.0.3

Published

Render Live Story content in your React based applications.

Downloads

13

Readme

🚀 Live Story - Client SDK

The Live Story Client SDK makes it easy to embed Live Stories in Next.js and Shopify Hydrogen apps, supporting SSR and client-side initialization out of the box.

It's designed to work seamlessly with App Router, use client components, and server-rendered content.


✨ Features

  • ✅ Compatible with Next.js App Router
  • ✅ Supports SSR + Client Hydration
  • ✅ Works with Shopify Hydrogen
  • ✅ Safe client-side initialization
  • ✅ Multi-language and multi-store support
  • ✅ Zero complex setup

📦 Installation

npm install ls-client-sdk
# or
yarn add ls-client-sdk

🧩 Types

The Live Story SDK exports TypeScript types to help you work with entries safely.

import type { LiveStoryEntry, LiveStoryProps } from 'ls-client-sdk/client';

// LiveStoryEntry type
{
  id: string;
  title: string;
  type: string;
  ssc?: string;           // Optional server-side content URL
  sys?: { id: string };    // Contentful system metadata
  coverImg?: string;      // Optional cover image URL
  ssr?: string;           // Optional pre-rendered SSR content
};

// LiveStoryProps type
{
  language?: string;      // Optional language code (default: "default")
  store?: string;         // Optional store context (default: "default")
  entry: LiveStoryEntry;  // The live story entry to render
};

🚀 Usage

Hydrogen (Remix)

export default function LiveStoryPage(){
  const {entry} = useLoaderData<typeof loader>();

  if (!entry) {
    return null;
  }

  return (
    <main>
        <LiveStory entry={entry} language="en" store="default" />
    </main>
  );
}

Next.js (App Router)

In Next.js App Router, LiveStory must be rendered from a Client Component, while data fetching and SSR happen in a Server Component.


Server Component (page.tsx)

import LiveStoryClient from './LiveStoryClient';

export default async function Page({ params }: { params: { id: string } }) {
  const entry = await fetchLiveStoryEntry(params.id);

  // Fetch SSR HTML (critical data)
  if (entry?.ssc) {
    entry.ssr = await fetch(entry.ssc).then(res => res.text());
  }

  return (
    <main>
      <LiveStoryClient entry={entry} />
    </main>
  );
}

Client Component (LiveStoryClient.tsx)

'use client';

import { LiveStory } from 'ls-client-sdk/client';
import type { LiveStoryEntry, LiveStoryProps } from 'ls-client-sdk/client';

export default function LiveStoryClient({ entry }: LiveStoryProps ) {
  if (!entry) return null;

  return (
    <LiveStory
      entry={entry}
      language="en"
      store="default"
    />
  );
}

🌐 Language & Store codes

You can customize the language and store for your Live Story by passing the optional language and store props to the LiveStory component.

  • language – sets the display language (default: "default"). Optional.
  • store – sets the store context (default: "default"). Optional.

Example

<LiveStory
  entry={entry}
  language="en"   // e.g., "en", "it", "fr"
  store="default" // e.g., "default", "us-store", "eu-store"
/>

🧾 Example: Fetching SSR Content for Live Story

Sometimes, you want to render the Live Story content on the server first (SSR) and then hydrate it on the client.
Here's an example of how you can fetch the ssc content (from a Contentful entry, or any other CMS you have) and attach it to your entry.

Server-side Fetch (Hydrogen)

// Example: fetch Live Story SSR content from Contentful entry in Hydrogen
async function loadCriticalData(args: Route.LoaderArgs) {
  const entry = await fetchLiveStoryEntry(args.params.id);

  let liveStorySSR = '';

  // Fetch SSR HTML if available
  if (entry?.ssc) {
    liveStorySSR = await fetch(entry.ssc)
      .then(res => res.text())
      .catch(err => {
        console.error('Failed to fetch Live Story SSR:', err);
        return '';
      });
  }

  // Enhance entry with SSR content
  entry.ssr = liveStorySSR;

  return {
    entry
  };
}

Server-side Fetch (Next.js)

// Example: fetch Live Story SSR content from Contentful entry in Next.js
export async function getServerSideProps(context) {
  const entry = await fetchLiveStoryEntry(context.params.id);

  let liveStorySSR = '';

  // Fetch SSR content if available
  if (entry?.ssc) {
    liveStorySSR = await fetch(entry.ssc)
      .then(res => res.text())
      .catch(err => {
        console.error('Failed to fetch Live Story SSR:', err);
        return '';
      });
  }

  // Enhance entry with SSR content
  entry.ssr = liveStorySSR;

  return {
    props: {
      entry
    },
  };
}