Skip to content

docs: routing integration guide; skill routing note (#190 docs half) - #308

Merged
allxsmith merged 2 commits into
mainfrom
docs/190-routing
Jul 14, 2026
Merged

allxsmith merged 2 commits into
mainfrom
docs/190-routing

Conversation

@allxsmith

@allxsmith allxsmith commented Jul 14, 2026 •

Copy link
Copy Markdown
Owner

Pull Request

Description

The docs half of #190: a new Routing Integration feature guide (docs/guides/features/routing) answering the three first-hour questions, plus a routing note in the layout skill so agents stop copying href="#" into routed apps.

  • bulma-ui (@allxsmith/bestax-bulma)
  • create-bestax (create-bestax) — ships the updated layout skill
  • docs (@allxsmith/bestax-docs) — new feature guide
  • Other: skills/bestax-layout-scaffold routing note

Everything is source-verified against current typings — and the issue's landscape has shifted since it was filed:

  • Menu.Item as={Link} to="…" is fully typed today (MenuItemProps has an index signature and explicitly forwards to) — the guide leads with it as the zero-friction case.
  • Button as={Link} type-checks now — the issue's TS2322 was fixed by feat(bulma-ui): make Button and Link as prop polymorphic (React.ElementType) #238 (polymorphic as). The guide documents the ButtonLink typed alias for to, the useNavigate alternative, and when to prefer each (real anchors vs. imperative side-effects).
  • Navbar.Item's gap is real and remains: to isn't in its prop type (runtime forwards it fine). The guide documents the recommended one-line typed alias; the API fix is now spec'd in [Feature] Navbar.Item: first-class router-link typing (accept to like Menu.Item) #306 (filed with this PR — index-signature parity with Menu.Item vs. proper generic polymorphic typing).
  • Active-route styling: useLocation().pathname driving the active prop (with a note on why NavLink's function-style props don't mix with the components' class handling).
  • Next.js: modern <Link> uses href, which is already typed — as={NextLink} href="…" needs no alias; pre-13 legacyBehavior noted.

Skill: layout-components.md's Navbar section gains a compact routing block (Menu.Item typed pattern, Navbar.Item alias, active from useLocation, link to the guide).

Related Issue(s)

Closes #190
Refs #238 (Button polymorphism, already shipped), #306 (new — Navbar.Item first-class to typing)

Type of Change

  • Documentation

Checklist

  • My code follows the project style guidelines
  • I have performed a self-review of my code
  • I have added/updated documentation as needed
  • All new and existing tests passed (no package code changed; prettier + format:check green; full docs build green — new page reachable via the autogenerated guides sidebar)
  • If this PR changes commands, conventions, or package structure, the affected CLAUDE.md files are updated (none affected)

Additional Context

Code samples in the guide are plain tsx blocks (not tsx live) since they import react-router-dom, which isn't in the docs live scope.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pohc8xLkdx4gwXkW3xd7up


Generated by Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a routing guide showing how to integrate Bulma-based components with client-side navigation using router Link patterns (including as usage for menu items and buttons).
    • Documented how to drive active styling from router location, plus TypeScript considerations for Navbar.Item.
    • Added guidance on imperative navigation and external links, and included a Next.js Link behavior comparison.
    • Updated the Navbar reference with a routing note and links to the full guide.

New Routing Integration feature guide covering the three first-hour
questions from #190, source-verified against current typings:

- Menu.Item as={Link} to=... is fully typed today (index signature +
  explicit to forwarding).
- Navbar.Item as={Link} forwards to at runtime but to isn't in its prop
  type — the guide documents the one-line typed alias; first-class
  typing is now tracked in #306.
- Button's as is polymorphic since #238, so ButtonLink (typed alias) or
  useNavigate are the two navigation patterns; active-route styling via
  useLocation + the active prop; Next.js needs no alias (href is typed).

The layout skill's Navbar section gains a routing note (stop copying
href="#" in routed apps) pointing at the guide.

Closes #190

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pohc8xLkdx4gwXkW3xd7up
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ae8bc967-3fdc-485f-b29b-a28d951d6594

📥 Commits

Reviewing files that changed from the base of the PR and between 5ee9f7d and 9fc7eae.

📒 Files selected for processing (2)
  • docs/docs/guides/features/routing.md
  • skills/bestax-layout-scaffold/references/layout-components.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • skills/bestax-layout-scaffold/references/layout-components.md
  • docs/docs/guides/features/routing.md

Walkthrough

Added routing documentation for Bestax components covering React Router and Next.js links, button navigation, active-route styling, TypeScript aliases, and related API references. Updated the Navbar skill reference with concise routing guidance.

Changes

Routing documentation

Layer / File(s) Summary
Routing integration guide
docs/docs/guides/features/routing.md
Documents router links for Menu.Item and Navbar.Item, Button navigation patterns, active-route styling, Next.js link behavior, and related references.
Navbar routing reference
skills/bestax-layout-scaffold/references/layout-components.md
Adds guidance for router links, TypeScript typing, active-route state, and the full routing guide.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

Possibly related PRs

  • allxsmith/bestax#238 — Adds polymorphic as support that the routing documentation demonstrates for router link components.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the docs routing integration guide and the layout skill note, matching the PR's main changes.
Description check ✅ Passed The description covers the changed packages, issue link, change type, checklist, and additional context, with all required sections present.
Linked Issues check ✅ Passed The docs and skill updates address the issue's router link, button navigation, active-route, and Next.js guidance requirements.
Out of Scope Changes check ✅ Passed The changes stay within documentation and skill guidance for routing, with no unrelated code or scope creep visible.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/190-routing

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Preview Deployment

Preview URL: https://d1153e2d.bestax.pages.dev

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/docs/guides/features/routing.md`:
- Around line 19-20: The routing documentation overstates Menu.Item’s static
typing guarantees. In docs/docs/guides/features/routing.md lines 19-20 and
skills/bestax-layout-scaffold/references/layout-components.md lines 227-230,
replace “fully type-checked” with wording that accurately describes router-prop
forwarding and the available typing without claiming router-specific validation.
- Around line 118-122: Update the Menu.Item active condition in the routing
example to match the /customers route only when the pathname is exactly
/customers or begins with /customers/. Preserve active highlighting for customer
subroutes while excluding similarly prefixed routes such as /customerships.
- Around line 137-149: Correct the Next.js version guidance in the routing
documentation: state that legacyBehavior/passHref apply to Next.js 13–15, that
Next.js 16 removes them, and that pre-13 requires the anchor-child pattern by
default. Replace the current compatibility example with an explicit Link wrapper
using Navbar.Item as="a" for older versions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2abf4560-9b53-4a9b-8337-635f0694025e

📥 Commits

Reviewing files that changed from the base of the PR and between f3d3c9e and 5ee9f7d.

📒 Files selected for processing (2)
  • docs/docs/guides/features/routing.md
  • skills/bestax-layout-scaffold/references/layout-components.md

Comment thread docs/docs/guides/features/routing.md Outdated
Comment thread docs/docs/guides/features/routing.md
Comment thread docs/docs/guides/features/routing.md Outdated
Comment thread docs/docs/guides/features/routing.md Outdated
Comment on lines +19 to +20
`Menu.Item` supports routers out of the box — pass the router's link component via `as`, and
`to` (or any other router prop) is forwarded to it, fully type-checked:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"fully type-checked" overstates Menu.Item's typing — 🟡 Minor · API

What: Menu.Item accepts to only because MenuItemProps has an index signature ([key: string]: unknown, Menu.tsx:153). That makes to (and any other extra prop) type unknown — accepted, but not validated. <Menu.Item as={Link} to={42}> or a typo'd too="/x" both compile with no error.

Why it matters: The page's whole thesis is TypeScript typing precision (it carefully explains why Navbar.Item needs a cast). Calling Menu's forwarding "fully type-checked" is the opposite of what the index signature does — a reader trusting the compiler here gets no safety net on router props.

Fix: soften the claim to what's actually true (it compiles / is forwarded), without promising type-checking:

Suggested change
`Menu.Item` supports routers out of the box — pass the router's link component via `as`, and
`to` (or any other router prop) is forwarded to it, fully type-checked:
`Menu.Item` supports routers out of the box — pass the router's link component via `as`, and
`to` (or any other router prop) is forwarded to it, no cast required:
Source

Menu.tsx:

export interface MenuItemProps ... {
  as?: React.ElementType;
  [key: string]: unknown;   // <- accepts `to`, but as `unknown`
}

By contrast NavbarItemProps extends only AnchorHTMLAttributes with no index signature, which is exactly why to errors there — the section below documents that correctly.

- Menu.Item wording no longer claims full type-checking: the index
  signature accepts extra keys as unknown — compiles without casts, but
  no router-prop validation (both docs and skill note reworded).
- Active-route example uses a boundary match (exact or /customers/
  prefix) so /customerships can't ring the bell.
- Next.js version ranges corrected: 13-15 also accepted the deprecated
  legacyBehavior/passHref, 16 removes them, and pre-13 needed the anchor
  child — now shown with the explicit wrapper pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pohc8xLkdx4gwXkW3xd7up

Copy link
Copy Markdown
Owner Author

All four review findings (CodeRabbit ×3 + the deep review's, which duplicates CodeRabbit's first) verified and fixed in 9fc7eae:

  1. "fully type-checked" overstated Menu.Item's typing (both reviewers — confirmed): the index signature accepts extra keys as unknown, so to={42} or a typo'd prop compiles. Both the guide and the skill note now say it compiles without errors or casts while explicitly noting the extra props aren't validated against the router's own types.
  2. Prefix false positive (confirmed): the active-route example now uses the boundary match (pathname === '/customers' || pathname.startsWith('/customers/')), so /customerships doesn't light up.
  3. Next.js version ranges (confirmed — my error): legacyBehavior/passHref were the 13–15 compatibility path and are removed in 16; pre-13 needed the <a> child. The section now states the ranges correctly and shows the explicit wrapper pattern (<NextLink href passHref><Navbar.Item as="a">…) for older versions.

Generated by Claude Code

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review — 1 finding

# Severity Area Finding Location
1 🟡 Minor API "fully type-checked" overstates Menu.Item typing — the index signature accepts to as unknown, so router props aren't actually validated docs/docs/guides/features/routing.md:19-20

Overall: This is a docs-only PR and the technical content is sound — I source-verified every claim against the current typings. Menu.Item's index signature + explicit to/href forwarding makes as={Link} to=… compile and work; Navbar.Item genuinely lacks the extra prop in its type (no index signature over AnchorHTMLAttributes), so the documented cast alias is the correct workaround; Button's as is polymorphic and forwards to via anchorRest when rendered as a non-button. All three cross-links resolve, the skill URL is right, and sidebar_position: 6 doesn't collide. The one thing to fix is a wording overstatement: Menu's forwarding isn't "type-checked" — the index signature makes those props unknown, so there's no compiler safety on to. Human should focus on that single phrasing tweak; everything else is good to merge.

🏄 Clean little docs set, dude — the routing waves are mapped out right and every link lands. Just one gnarly word, "type-checked," that's telling surfers the water's safer than it really is. Patch that phrase and this one's cruising straight to shore.

@github-actions

Copy link
Copy Markdown
Contributor

Preview Deployment

Preview URL: https://d5491dbb.bestax.pages.dev

@allxsmith
allxsmith merged commit 7136823 into main Jul 14, 2026
18 checks passed
@allxsmith
allxsmith deleted the docs/190-routing branch July 14, 2026 23:40
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bestax-release-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Integration] No documented story for using bestax with React Router / Next.js (client-side navigation)

2 participants