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: