From 3f335a362204ea8fe44c70686c700469a97efb99 Mon Sep 17 00:00:00 2001 From: Stephan Cilliers <5469870+stephancill@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:50:50 +0200 Subject: [PATCH 1/2] docs: farcasterHubContext middleware usage instructions --- docs/pages/middleware/farcasterHubContext.mdx | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/pages/middleware/farcasterHubContext.mdx b/docs/pages/middleware/farcasterHubContext.mdx index 3c3a10907..55ab98fa9 100644 --- a/docs/pages/middleware/farcasterHubContext.mdx +++ b/docs/pages/middleware/farcasterHubContext.mdx @@ -2,9 +2,11 @@ Fetches additional context about the message from a Farcaster hub. -## Usage +## Setup + +Add the `farcasterHubContext` middleware to your `createFrames` call: -```tsx +```tsx [frames.ts] // ... import { farcasterHubContext } from "frames.js/middleware"; @@ -18,6 +20,26 @@ const frames = createFrames({ }); ``` +## Usage + +Use the added context in your message handler: + +```tsx [route.tsx] +import { frames } from "./frames"; + +export const POST = frames(async (ctx) => { + if (!ctx.message?.isValid) { + throw new Error("Invalid message"); + } + + return { + image:
Message from {ctx.message?.requesterFid}
, + }; +}); +``` + +For all the added context see the [`getFrameMessage`](/reference/js/getFrameMessage) function reference. + ## Options ### `hubHttpUrl` From 6c1a22c03aac4d590733c640b9aef044b65dc1df Mon Sep 17 00:00:00 2001 From: Stephan Cilliers <5469870+stephancill@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:53:12 +0200 Subject: [PATCH 2/2] chore: changeset --- .changeset/four-cheetahs-tease.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/four-cheetahs-tease.md diff --git a/.changeset/four-cheetahs-tease.md b/.changeset/four-cheetahs-tease.md new file mode 100644 index 000000000..704a31c10 --- /dev/null +++ b/.changeset/four-cheetahs-tease.md @@ -0,0 +1,5 @@ +--- +"docs": patch +--- + +docs: improve farcasterHubContext docs