Skip to content

Latest commit

 

History

History

plugin-vite

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

@van1s1mys/ai-router-plugin-vite

Vite plugin for @van1s1mys/ai-router — auto-scans your pages directory and exposes routes via a virtual module.

Install

npm install @van1s1mys/ai-router @van1s1mys/ai-router-plugin-vite

Setup

// vite.config.ts
import { defineConfig } from 'vite';
import { aiRouter } from '@van1s1mys/ai-router-plugin-vite';

export default defineConfig({
  plugins: [aiRouter()],
});
// app.ts
import { SmartRouter } from '@van1s1mys/ai-router';
import { routes } from 'virtual:ai-router';

const router = new SmartRouter({ routes });
await router.ready;

const result = await router.search('how much does it cost?');

Options

aiRouter({
  // Directories to scan (default: auto-detect)
  dirs: ['src/pages'],

  // File extensions to include
  extensions: ['.tsx', '.jsx', '.vue', '.svelte', '.astro', '.md', '.mdx'],

  // Patterns to exclude
  exclude: ['_layout', 'api/'],

  // Additional manual routes merged with scanned ones
  routes: [
    { path: '/pricing', title: 'Pricing', description: 'cost, plans' },
  ],
});

Route annotations

Add @ai-route comments to page files for richer metadata:

// @ai-route title="Pricing" description="plans, cost, billing, subscription"

export default function PricingPage() { ... }

HMR

Routes are re-scanned automatically when files in the scanned directories change.

License

MIT © IvanMalkS