Skip to content

Commit 8e49faa

Browse files
added sharing on farcaster
1 parent 7b38d8f commit 8e49faa

4 files changed

Lines changed: 13 additions & 17 deletions

File tree

packages/nextjs/app/api/opengraph-image/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function GET() {
1616
</div>
1717
)} */}
1818
<h1 tw="text-8xl text-white">THE RANKR APP!</h1>
19-
<p tw="text-5xl mt-4 text-white opacity-80">(by Romi, Noad & Diana)</p>
19+
<p tw="text-5xl mt-4 text-white opacity-80">(by Romi & Noad)</p>
2020
</div>
2121
),
2222
{

packages/nextjs/app/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useCallback, useEffect, useMemo, useState } from "react";
4+
import { sdk } from "@farcaster/miniapp-sdk";
45
import type { NextPage } from "next";
56
import { formatEther, parseEther } from "viem";
67
import { useAccount } from "wagmi";
@@ -185,6 +186,11 @@ const Home: NextPage = () => {
185186
[writeRank5],
186187
);
187188

189+
// After your app is fully loaded and ready to display
190+
useEffect(() => {
191+
sdk.actions.ready();
192+
}, []);
193+
188194
// All hooks above this point; render based on connection state below
189195

190196
if (!connectedAddress) {

packages/nextjs/app/share/[fid]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function generateMetadata({ params }: { params: Promise<{ fid: stri
1313
const imageUrl = `${APP_URL}/api/opengraph-image?fid=${fid}`;
1414

1515
return {
16-
title: `${APP_NAME} - Share`,
16+
title: `${APP_NAME} - Rank Your Songs!`,
1717
openGraph: {
1818
title: APP_NAME,
1919
description: APP_DESCRIPTION,

packages/nextjs/components/ui/ShareButton.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useCallback, useMemo, useState } from "react";
4+
import sdk from "@farcaster/miniapp-sdk";
45
import { buildShareUrl } from "~~/lib/share";
56

67
type ShareIntent = {
@@ -27,21 +28,10 @@ const ShareButton: React.FC<ShareButtonProps> = ({ label = "Share", className =
2728
const handleShare = useCallback(async () => {
2829
try {
2930
setIsSharing(true);
30-
const text = intent.text;
31-
const url = targetEmbed;
32-
33-
// Prefer Web Share API if available (nice UX on mobile)
34-
if (typeof window !== "undefined" && (navigator as any).share) {
35-
await (navigator as any).share({ text, url });
36-
return;
37-
}
38-
39-
// Fallback: open Warpcast composer with prefilled text
40-
const params = new URLSearchParams();
41-
params.set("text", text);
42-
if (url) params.set("embeds[]", url);
43-
const warpUrl = `https://warpcast.com/~/compose?${params.toString()}`;
44-
window.open(warpUrl, "_blank", "noopener,noreferrer");
31+
await sdk.actions.composeCast({
32+
text: "Rank these songs! 🚀",
33+
embeds: [`https://blockboom-nextjs.vercel.app/share/dummy_fid`],
34+
});
4535
} catch (err) {
4636
console.error("Share failed", err);
4737
} finally {

0 commit comments

Comments
 (0)