Skip to content

Frog.castAction

Import

import { Frog } from 'frog'

Usage

/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
 
const app = new Frog()
 
app.castAction('/', (c) => {
  console.log('Apple and Banana')
  return c.res({ message: 'Action Succeeded' })
})
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2554 2345. Expected: // @errors: 2554 2345 Compiler Errors: index.tsx [2554] 111 - Expected 3-12 arguments, but got 2. [2345] 202 - Argument of type '{ message: string; }' is not assignable to parameter of type 'CastActionResponse'. Type '{ message: string; }' is not assignable to type '{ type: "message"; } & CastActionMessageResponse'. Property 'type' is missing in type '{ message: string; }' but required in type '{ type: "message"; }'.

Parameters

path

  • Type: string

Path of the route.

Read more.

/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
 
const app = new Frog()
 
app.castAction(
  '/foo/bar',
  (c) => {
    console.log('Apple and Banana')
    return c.res({ message: 'Action Succeeded' })
  }
) 
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2554 2345. Expected: // @errors: 2554 2345 Compiler Errors: index.tsx [2554] 111 - Expected 3-12 arguments, but got 2. [2345] 218 - Argument of type '{ message: string; }' is not assignable to parameter of type 'CastActionResponse'. Type '{ message: string; }' is not assignable to type '{ type: "message"; } & CastActionMessageResponse'. Property 'type' is missing in type '{ message: string; }' but required in type '{ type: "message"; }'.

handler

  • Type: (c: Context) => CastActionResponse

Handler function for the route.

/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
 
const app = new Frog()
 
app.castAction(
  '/foo/bar',
  (c) => {
    console.log('Apple and Banana')
    return c.res({ message: 'Action Succeeded' })
  }
) 
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2554 2345. Expected: // @errors: 2554 2345 Compiler Errors: index.tsx [2554] 111 - Expected 3-12 arguments, but got 2. [2345] 218 - Argument of type '{ message: string; }' is not assignable to parameter of type 'CastActionResponse'. Type '{ message: string; }' is not assignable to type '{ type: "message"; } & CastActionMessageResponse'. Property 'type' is missing in type '{ message: string; }' but required in type '{ type: "message"; }'.

Context Parameter

See the Cast Action Context API.

Action Response

See the Cast Action Response API.