Skip to content

Frog.castAction Response

The response returned from the .castAction handler.

import { Frog } from 'frog'
 
export const app = new Frog()
 
app.castAction('/', (c) => {
  return c.res({
    // ...
  })
})

headers

  • Type: Record<string, string>

HTTP response headers to set for the action.

import { Button, Frog } from 'frog'
 
export const app = new Frog()
 
app.castAction('/action/foo', (c) => {
  return c.res({
    headers: {
      'Cache-Control': 'max-age=0',
    },
    message: 'Success!',
    statusCode: 200
  })
})

message

  • Type: string

Message to show in the toast in the App that sent the action.

import { Button, Frog } from 'frog'
 
export const app = new Frog()
 
app.castAction('/', (c) => {
  return c.res({
    message: 'Action Succeeded!',
    statusCode: 200
  })
})

statusCode

  • Type: 200 | ClientErrorStatusCode | undefined
  • Default: 200.

HTTP Status code to respond with.

import { Button, Frog } from 'frog'
 
export const app = new Frog()
 
app.castAction('/', (c) => {
  return c.res({
    message: 'Action Succeeded!',
    statusCode: 200
  })
})