1.4.8 • Published 3 days ago

react-farcaster-embed v1.4.8

Weekly downloads
-
License
The Unlicense
Repository
github
Last release
3 days ago

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

  • Supports server components and client components
  • Shows the cast's author, their avatar and username, date when the cast was posted
  • Renders the cast's content with links
  • Shows the channel name and avatar
  • Shows counts for replies, likes, recasts + quotes, watches
  • Adds a link to the cast on Warpcast
  • Renders images inline
  • Renders videos inline
  • Renders rich embeds for links
  • 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;
}

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.

1.4.8

3 days ago

1.4.7

1 month ago

1.4.6

2 months ago

1.3.7

2 months ago

1.4.5

2 months ago

1.4.4

2 months ago

1.4.3

2 months ago

1.4.2

2 months ago

1.4.1

2 months ago

1.4.0

2 months ago

1.3.8

2 months ago

1.3.6

2 months ago

1.3.5

2 months ago

1.3.4

2 months ago

1.3.3

2 months ago

1.3.2

2 months ago

1.3.1

2 months ago

1.3.0

2 months ago

1.2.4

2 months ago

1.2.0

3 months ago

1.2.3

3 months ago

1.2.2

3 months ago

1.2.1

3 months ago

1.1.1

4 months ago

1.1.0

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago