Skip to content

app.changePage

Change the active page of a Buttonize app.

Terminal window
Action.buttonize.app.changePage(pageName)

Usage

lib/MyStack.ts
import { Action, ButtonizeApp, Display, Input } from 'buttonize/cdk'
new ButtonizeApp(this, 'DemoApp')
.page('DemoPage',
body: [
Display.text('Wanna see the next page?'),
Input.button({
label: 'Yes!',
onClick: Action.buttonize.app.changePage('SecondPage'),
})
]
)
.page('SecondPage',
body: [
Display.text('Welcome to the second page!'),
]
)

Arguments

changePage simply takes the name of the page you’d like to activate as a string. It must match the name of a page declared in the app via the page method.

The page name argument can also accept conditional expressions. So logic like:

Action.buttonize.app.changePage(
B.if(B.eq('{{runtimeStateVariable}}', 'true'), 'Page1', 'Page2')
)

is possible.