Skip to content

feat: add route guard and meta support + ci upgrade#2

Merged
wmzy merged 14 commits intonative-router:mainfrom
nu-xin:main
Mar 1, 2026
Merged

feat: add route guard and meta support + ci upgrade#2
wmzy merged 14 commits intonative-router:mainfrom
nu-xin:main

Conversation

@nu-xin
Copy link
Contributor

@nu-xin nu-xin commented Mar 1, 2026

Changes

Features

  • Add guard support for route-level authorization
  • Add meta support for route metadata
  • Add useParams, useLocation, useMatched hooks

CI

  • Upgrade Node.js version from 16.x to 20.x/22.x
  • Update GitHub Actions to latest versions
  • Switch from npm to pnpm commands

Usage

Route Guard

const routes = [
  {
    path: "/admin",
    guard: (to, from, ctx) => {
      if (!isAuthenticated) return false;
      return true;
    },
    meta: { requiresAuth: true },
    children: [...]
  }
];

New Hooks

import { useParams, useLocation, useMatched } from "@native-router/react";

function Profile() {
  const { id } = useParams<{ id: string }>();
  const location = useLocation();
  const matched = useMatched();
  // ...
}

@wmzy wmzy merged commit e0130e3 into native-router:main Mar 1, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants