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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@builder.io/sdk-react-nextjs

v0.17.0

Published

Builder.io RSC SDK for NextJS App Directory

Downloads

1,988

Readme

When should I use this SDK (please read carefully)

  • you should ONLY use this SDK if you are trying to register your RSCs (react server components) in Builder. That is its only advantage over our standard React SDKs.
  • our Gen1 and Gen2 React SDKs work perfectly well with all versions of Next.js. The only feature they do not support is registration of RSCs.
  • this SDK only works in the NextJS App Directory.

To allow registering RSCs, this SDK must make compromises. Most notably:

  • it does not support interactive Builder features within the rendered content (such as updating dynamic bindings, state, actions etc.). As of today, there are no workarounds around these limitations, due to how RSCs work. See the features grid for more information.
  • the visual editor experience is laggy, as it requires network roundtrips to the customer's servers for each edit. We are working on improving this.

this SDK is marked as "Beta" due to the missing features mentioned above. It is however actively maintained and developed alongside all other SDKs.

Builder.io React NextJS SDK (BETA)

This is the Builder NextJS SDK, @builder.io/sdk-react-nextjs. It is intended to be used only with NextJS's app directory, and has hard dependencies on NextJS-specific functionality that only works in the app directory.

Usage

When registering a custom component, you will need to add the isRSC: true option to the component. For example:

// CatFacts.tsx
async function CatFacts() {
  const catFacts = await fetch('https://cat-fact.herokuapp.com/facts').then(
    (x) => x.json()
  );
  return (
    <div>
      Here are some cat facts from an RSC:
      <ul>
        {catFacts.slice(3).map((fact) => (
          <li key={fact._id}>{fact.text}</li>
        ))}
      </ul>
    </div>
  );
}

export const CatFactsInfo = {
  name: 'CatFacts',
  component: CatFacts,
  // You must add the below option or the SDK will fail to render.
  isRSC: true,
};

And in your page.tsx, you can use the custom component like this:

// page.tsx
import {
  Content,
  fetchOneEntry,
  getBuilderSearchParams,
} from '@builder.io/sdk-react-nextjs';
import { CatFactsInfo } from './CatFacts';

export default async function Page(props) {
  const urlPath = '/' + (props.params?.slug?.join('/') || '');

  const content = await fetchOneEntry({
    model: 'page',
    apiKey,
    options: getBuilderSearchParams(props.searchParams),
    userAttributes: { urlPath },
  });

  return (
    <Content
      content={content}
      model="page"
      apiKey={apiKey}
      customComponents={[CatFactsInfo]}
    />
  );
}

For more usage information, look at the examples.

Mitosis

This SDK is generated by Mitosis. To see the Mitosis source-code, go here.

Feature Support

To check the status of the SDK, look at these tables.

Getting Started

npm install @builder.io/sdk-react-nextjs

Examples