Frog.castAction 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()
app.castAction('/', (c) => {
return c.res({/* ... */})
})
actionData
- Type:
CastActionData
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()
app.castAction('/', (c) => {
const { actionData } = c
const { castId, fid, messageHash, network, timestamp, url } = actionData
return c.res({/* ... */})
})
error
- Type:
(error: BaseError) => TypedResponse
Error response.
import { Button, Frog } from 'frog'
export const app = new Frog()
app.castAction('/', (c) => {
return c.error({/* ... */})
})
req
- Type:
Request
import { Button, Frog } from 'frog'
export const app = new Frog()
app.castAction('/', (c) => {
const { req } = c
return c.res({/* ... */})
})
res
- Type:
(response: CastActionResponse) => CastActionResponse
The action response.
import { Button, Frog } from 'frog'
export const app = new Frog()
app.castAction('/', (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()
app.use(async (c, next) => {
c.set('message', 'Frog is cool!!')
await next()
})
app.castAction('/', (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()
app.castAction('/', (c) => {
const { verified } = c
return c.res({/* ... */})
})