ryukoposting / kroutes

Client-side routing for Karax

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KRoutes is a client-side router for karax.

Features

  • Easy to retrofit into existing Karax apps.
  • Support for both client-side and server-side HTML rendering.
  • Extensibility via method overloading.
  • Utility procs for site navigation.
  • Routing with path parameters.
  • Optional RAM-cached SSR responses to reduce server load.
  • Only one dependency: Karax (which you're using anyway, if you're using this package!)

Simple Example

include karax/prelude
import kroutes

let router = newRouter()

router.addRoute("/") do (ctx: Context) -> VNode:
  buildHtml(main):
    button(onclick = goto("/clicked")): text "Click the button."
    button(onclick = goto("/blog_post")): text "Go to the blog post."

router.addRoute("/clicked") do (ctx: Context) -> VNode:
  buildHtml(main):
    text "You clicked the button!"
    button(onclick = goBack()): text "Go back."

router.addSsrRoue("/blog_post")

setRenderer(router)

Demo app

The demo/ directory contains a simple web app using Prologue, Karax, and KRoutes. It uses both client-side and server-side rendering.

About

Client-side routing for Karax


Languages

Language:Nim 100.0%