presentation-screenScreen

Observe and control navigation within the app.

circle-exclamation

Listen to navigation

// Listen to navigation
ctx.screen.onNavigate(e => {
    // User navigated to the 'One Piece' anime page
    console.log(e.pathname) // /entry
    console.log(e.searchParams) // { "id": "21" }
})

// Or as a state
const screen = ctx.screen.getState()
const isAnimeEntry = ctx.computed(() => screen.get().current === "entry", [screen])
isAnimeEntry.get()
// Navigate to the 'Sakamoto Days' anime page
ctx.screen.navigateTo("/entry", { "id": "177709" })

Reload the screen

Get the current screen

Calling this will trigger onNavigate

This is useful if you want to know the current screen without having to wait for the user to navigate.

Last updated