vite-routing-rules

Set up Vite React SPA routing with createBrowserRouter, auth guards, and Zod-validated search parameters.

3|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/mauriciodelrio/delriodev-skills --skill vite-routing-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vite-routing-rules
Source: https://github.com/mauriciodelrio/delriodev-skills/tree/main/es-skills/software/frontend/vite-routing-rules
Command: npx skills add https://github.com/mauriciodelrio/delriodev-skills --skill vite-routing-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps developers set up robust client‑side routing in a Vite‑based React SPA, providing typed search parameters, protected layout routes, and lazy‑loaded pages, eliminating repetitive boilerplate and hard‑coded strings.

Core Features & Use Cases

  • Typed routing with createBrowserRouter – central definition of public and protected routes.
  • Layout components using Outlet – shared UI (sidebar, auth screens) without duplication.
  • Client‑side auth guards – simple UX redirects for unauthenticated users.
  • Zod‑validated search params – safe handling of query strings.
  • Lazy page loading – code‑splitting for faster initial load.
  • Centralized constant routes – avoids string scattering.

Use case example: building a dashboard application where some routes require authentication and others are public, with query filters typed via Zod.

Quick Start

Create a Vite React Router v6 routing configuration with protected layouts, typed search parameters, and lazy‑loaded pages.

Frequently Asked Questions about vite-routing-rules

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

FAQPage Schema
How do I set up protected routes with React Router v6 in a Vite SPA?

You can set up protected routes in a Vite SPA using createBrowserRouter by defining layout components with Outlet and wrapping protected pages with client-side auth guard wrappers that redirect unauthenticated users.

How do I validate search parameters in React Router v6?

You can validate search parameters in React Router by applying Zod schemas to parse and type query strings, ensuring safe handling of URL parameters before they reach your page components.

What is the best way to lazy load page components with Vite and React Router?

The best way to lazy load page components with Vite is using React Router's built-in code-splitting with dynamic imports, which reduces the initial bundle size and speeds up the first page load.

How do I centralize route constants in a React Router configuration?

Centralize route constants by defining all path strings in a single exported module before passing them to createBrowserRouter, which avoids string scattering and improves navigation maintainability.

Does this routing setup require Zod for query string validation?

No, Zod is not strictly required, but it is used to validate search parameters and provide typed query strings, eliminating repetitive boilerplate and ensuring safe parsing of URL filters.