🚧 VeloxKit is pre-release software. APIs may change before v1.0. Get started →
Documentation
Packages
@velox/router

@velox/router Stable

Named-route history-stack router for VeloxKit desktop apps. No URLs, no file system — just a stack of { name, params } entries.

Install

npm install @velox/router

Quick start

import { Router, Route } from '@velox/router'
import HomeScreen from './screens/HomeScreen'
import SettingsScreen from './screens/SettingsScreen'
 
export default function App() {
  return (
    <Router initialRoute="home">
      <Route name="home"     component={HomeScreen} />
      <Route name="settings" component={SettingsScreen} />
    </Router>
  )
}

API

<Router>

PropTypeDefaultDescription
initialRoutestringfirst declared routeName of the initial screen
childrenReactNode<Route> declarations

Renders the component for the current history entry. Only the active screen is rendered.

<Route>

PropTypeDescription
namestringRoute identifier — used with navigate()
componentComponentTypeScreen component to render

Route declarations always render null — they are read by <Router> at mount time.

useNavigate()

const navigate = useNavigate()

Returns the navigate function. Stable across renders.

navigate('detail', { id: 42 })           // push
navigate('back')                          // pop
navigate('home', {}, { replace: true })  // replace top of stack
ArgumentTypeDescription
namestringRoute name — or 'back' to pop
paramsobjectOptional params passed to the screen
opts.replacebooleanReplace current entry instead of pushing

useRoute()

const { name, params, canGoBack } = useRoute()

Returns the current route state.

FieldTypeDescription
namestring | nullCurrent route name
paramsobjectParams passed via navigate()
canGoBackbooleantrue when history stack depth > 1

Full guide

See the Routing guide for patterns, sidebar layouts, TypeScript types, and back-button examples.