Skip to content

Frog.action

Import

import { Frog } from 'frog'

Usage

import { Button, Frog } from 'frog'
 
const app = new Frog()
 
app.action('/', (c) => {
  console.log('Apple and Banana')
  return c.res({ message: 'Action Succeeded' })
})

Parameters

path

  • Type: string

Path of the route.

Read more.

import { Button, Frog } from 'frog'
 
const app = new Frog()
 
app.action(
  '/foo/bar',
  (c) => {
    console.log('Apple and Banana')
    return c.res({ message: 'Action Succeeded' })
  }
) 

handler

  • Type: (c: Context) => ActionResponse

Handler function for the route.

/** @jsxImportSource frog/jsx */
// ---cut---
import { Button, Frog } from 'frog'
 
const app = new Frog()
 
app.action(
  '/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: 1128. Expected: // @errors: 1128 Compiler Errors: index.tsx [1128] 286 - Declaration or statement expected.

Context Parameter

See the Action Context API.

Action Response

See the Action Response API.