jac-cl-routing

Implements client-side routing in Jac apps using file-based pages or manual Router declarations.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-cl-routing-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-cl-routing
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-cl-routing
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-cl-routing-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building multi-page Jac client applications requires choosing and correctly wiring a routing system, and common mistakes like mixing file-based routing with a manual Router or exporting an app that ignores children silently break navigation. This Skill provides the conventions, code patterns, and pitfalls for setting up routing correctly the first time. ## Core Features & Use Cases - File-based routing: Turn files in a pages/ directory into routes by convention, including dynamic [id] params, catch-all routes, nested layouts with <Outlet/>, and (auth) protected route groups. - Manual routing: Declare an explicit route table with <Router>, <Routes>, and <Route> for apps that prefer one file of route declarations. - Navigation APIs: Use Link, useNavigate, Navigate, useLocation, and useParams correctly, including query-string parsing with URLSearchParams. - Use Case: When adding a dashboard with protected pages and dynamic user detail screens to a Jac web app, use this Skill to structure pages/, wire main.jac's app(children) export, and avoid the silent route-dropping failure. ## Quick Start Add a multi-page flow with a protected dashboard and a user detail page to my Jac app using file-based routing.

Frequently Asked Questions about jac-cl-routing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add multiple pages to a Jac client app?

Create a pages/ directory where each file with a public export returning JsxPage becomes a route by convention. The filename sets the URL: index.jac maps to the directory root, about.jac to /about, and [id].jac to a dynamic :id segment.

File-based routing vs manual Router in Jac, which should I use?

File-based routing is the recommended default since files in pages/ become routes with no Router wiring. Manual <Router>/<Routes> suits apps wanting one explicit route table, but never mix the two systems in one app.

How do I protect routes with authentication in Jac?

Place pages inside a route group folder named (auth)/ and the build system automatically wraps every page inside with an AuthGuard. The default unauthenticated redirect is /login, configurable via auth_redirect in jac.toml.

Why are my Jac pages routes not rendering?

The most common cause is a main.jac app export that ignores its children argument, which silently drops every route while builds pass. Export def:pub app(children) that renders children inside JSX, such as a fragment or provider wrapper.

How do I read URL params and query strings in Jac?

Use useParams() and access values by subscript like params["id"], since dot access fails and missing params return undefined. For query strings, parse useLocation().search with new(URLSearchParams, location.search).

Why does refreshing a deep link 404 in production?

Routing uses clean BrowserRouter URLs, so any production host must serve the app HTML for extensionless non-API paths. jac start handles this SPA fallback automatically when base_route_app is set, but other hosts need equivalent configuration.