@kosmojs/react-generator
v0.0.24
Published
Bridges KosmoJS directory-based routing with React Router, automatically generating route configurations, type-safe navigation components, and loader integration.
Downloads
171
Readme
@kosmojs/react-generator
Bridges KosmoJS directory-based routing with React Router, automatically generating route configurations, type-safe navigation components, and loader integration.
Installation
npm install -D @kosmojs/react-generatorpnpm install -D @kosmojs/react-generatoryarn add -D @kosmojs/react-generatorUsage
Add to your source folder's vite.config.ts:
import reactPlugin from "@vitejs/plugin-react";
import devPlugin from "@kosmojs/dev";
import reactGenerator from "@kosmojs/react-generator";
export default {
plugins: [
reactPlugin(),
devPlugin(apiurl, {
generators: [
reactGenerator(),
// other generators...
],
}),
],
}What It Generates
- Router configuration - React Router setup with lazy-loaded routes
- Type-safe Link component - Navigation with autocomplete and compile-time checks
- Loader integration - Automatic loader function detection and execution
- Application structure - App.tsx, router.tsx, and entry points with Suspense
- Route definitions - Complete route mapping from
pagesdirectory
Features
- 🔄 Watch-based route generation
- 🎯 End-to-end type safety
- ⚡ Code splitting with lazy loading
- 🔗 Type-safe Link with parameter validation
- 📦 React Router v6+ integration
- 🎨 Custom template support via glob patterns
Documentation
Complete documentation: kosmojs.dev
License
MIT
