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.

/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
 
export const app = new Frog()
 
app.castAction('/', (c) => {
  return c.res({
    message: 'Action Succeeded!',
    statusCode: 200,
  })
})
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2554 2353. Expected: // @errors: 2554 2353 Compiler Errors: index.tsx [2554] 120 - Expected 3-12 arguments, but got 2. [2353] 217 - Object literal may only specify known properties, and 'statusCode' does not exist in type 'CastActionResponse'.

link

  • Type: string | undefined

An optional URL. Must be http:// or https:// protocol. If present, clients must display the message as an external link to this URL.

/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
 
export const app = new Frog()
 
app.castAction('/', (c) => {
  return c.res({
    message: 'Action Succeeded!',
    link: 'https://frog.fm',
    statusCode: 200,
  })
})
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2554 2353. Expected: // @errors: 2554 2353 Compiler Errors: index.tsx [2554] 120 - Expected 3-12 arguments, but got 2. [2353] 246 - Object literal may only specify known properties, and 'statusCode' does not exist in type 'CastActionResponse'.

statusCode

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

HTTP Status code to respond with.

/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
 
export const app = new Frog()
 
app.castAction('/', (c) => {
  return c.res({
    message: 'Action Succeeded!',
    statusCode: 200,
  })
})
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2554 2353. Expected: // @errors: 2554 2353 Compiler Errors: index.tsx [2554] 120 - Expected 3-12 arguments, but got 2. [2353] 200 - Object literal may only specify known properties, and 'statusCode' does not exist in type 'CastActionResponse'.