Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: farcasterHubContext middleware usage instructions #267

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
docs: farcasterHubContext middleware usage instructions
stephancill committed Apr 2, 2024

Verified

This commit was signed with the committer’s verified signature.
stephancill Stephan Cilliers
commit 3f335a362204ea8fe44c70686c700469a97efb99
26 changes: 24 additions & 2 deletions docs/pages/middleware/farcasterHubContext.mdx
Original file line number Diff line number Diff line change
@@ -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: <div tw="flex">Message from {ctx.message?.requesterFid}</div>,
};
});
```

For all the added context see the [`getFrameMessage`](/reference/js/getFrameMessage) function reference.

## Options

### `hubHttpUrl`