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

react-farcaster-embed

v1.6.0

Published

Embed casts from Farcaster in your React app.

Downloads

1,752

Readme

react-farcaster-embed

react-farcaster-embed

Display an embedded cast from Farcaster in your React app. Works with Next.js SSR.

Examples

Live Demo

Features

  • [x] Supports server components and client components
  • [x] Shows the cast's author, their avatar and username, date when the cast was posted
  • [x] Renders the cast's content with links
  • [x] Shows the channel name and avatar
  • [x] Shows counts for replies, likes, recasts + quotes, watches
  • [x] Adds a link to the cast on Warpcast
  • [x] Renders images inline
  • [x] Renders videos inline
  • [x] Renders rich embeds for links
  • [x] Renders quoted casts with images and videos

Installation

npm i react-farcaster-embed
# or
yarn add react-farcaster-embed
# or
pnpm add react-farcaster-embed

Usage

Server Components

Add these imports inside your server component:

import { FarcasterEmbed } from "react-farcaster-embed";
import "react-farcaster-embed/dist/styles.css"; // include default styles or write your own


// use warpcast url
<FarcasterEmbed url="https://warpcast.com/pugson/0x4294c797" />

// or username and hash of the cast
<FarcasterEmbed username="dwr" hash="0x48d47343" />

Client Components

Add the CSS import inside _app.tsx if you are using Next.js Pages Router:

import "@/styles/globals.css";
import "react-farcaster-embed/dist/styles.css";
import type { AppProps } from "next/app";

export default function App({ Component, pageProps }: AppProps) {
  return <Component {...pageProps} />;
}

And then use the component in your client component using a special import:

import { FarcasterEmbed } from "react-farcaster-embed/dist/client";

// use warpcast url
<FarcasterEmbed url="https://warpcast.com/pugson/0x4294c797" />

// or username and hash of the cast
<FarcasterEmbed username="dwr" hash="0x48d47343" />

Styling

The embed will inherit your body color by default when you import the default stylesheet.

You can change the color of the component by changing its parent's color or adding custom CSS:

.farcaster-embed-container {
  color: purple;
}

Custom Endpoint

In case you need to self host the Warpcast Client API proxy, you can fork this repo and set the customEndpoint option in the FarcasterEmbed component.

Easiest way to do this is to make a wrapper component with that option applied. Example:

import { FarcasterEmbed as FCEmbed } from "react-farcaster-embed";

export const FarcasterEmbed = (props) => (
  <FCEmbed
    {...props}
    options={{
      customEndpoint: "https://your-endpoint.xyz/api/casts",
    }}
  />
);

Casts will be fetched from your custom proxy instead of the default one using this URL structure. Make sure your proxy supports it.

await fetch(`${options?.customEndpoint}/${username}/${hash}`);

Found it useful?

Follow me on Farcaster or Twitter.

Send me a tip in ETH or $DEGEN to

  • pugson.eth
  • 0x96a77560146501eAEB5e6D5B7d8DD1eD23DEfa23

Other projects

You might also like ENS Data for getting ENS records and avatars or ABI Data for grabbing smart contract ABIs remotely.