Skip to content

Frog.composerAction Context

The c object is the parameter of the route handlers. It contains context about the current cast action.

import { Frog } from 'frog'
 
export const app = new Frog({ title: 'Frog Frame' })
 
app.composerAction('/', (c) => {
  return c.res({/* ... */})
}, {/**/})

actionData

  • Type: ComposerActionData

Data from the action that was passed via the POST body from a Farcaster Client. See more.

import { Button, Frog } from 'frog'
 
export const app = new Frog({ title: 'Frog Frame' })
 
app.composerAction('/', (c) => {
  const { actionData } = c
  const { castId, fid, messageHash, network, timestamp, url, state: { cast: { text } } } = actionData
  return c.res({/* ... */})
}, {/**/})

error

  • Type: (error: BaseError) => TypedResponse

Error response.

import { Button, Frog } from 'frog'
 
export const app = new Frog({ title: 'Frog Frame' })
 
app.composerAction('/', (c) => {
  return c.error({/* ... */})
})

req

  • Type: Request

Hono request object.

import { Button, Frog } from 'frog'
 
export const app = new Frog({ title: 'Frog Frame' })
 
app.composerAction('/', (c) => {
  const { req } = c
  return c.res({/* ... */})
}, {/**/})

res

  • Type: (response: ComposerActionResponse) => ComposerActionResponse

The action response.

import { Button, Frog } from 'frog'
 
export const app = new Frog({ title: 'Frog Frame' })
 
app.composerAction('/', (c) => {
  return c.res({/* ... */})
}, {/**/})

var

  • Type: HonoContext['var']

Extract a context value that was previously set via set in Middleware.

import { Button, Frog } from 'frog'
 
export const app = new Frog({ title: 'Frog Frame' })
 
app.use(async (c, next) => {
  c.set('message', 'Frog is cool!!')
  await next()
})
 
app.composerAction('/', (c) => {
  const message = c.var.message
  return c.res({/* ... */})
}, {/**/})

verified

  • Type: boolean

Whether or not the actionData (and buttonIndex) was verified by the Farcaster Hub API.

import { Button, Frog } from 'frog'
 
export const app = new Frog({ title: 'Frog Frame' })
 
app.composerAction('/', (c) => {
  const { verified } = c
  return c.res({/* ... */})
}, {/**/})