diff --git a/docs/content/1.guide/1.what-is-a-router.md b/docs/content/1.guide/1.what-is-a-router.md index ad89eaa5..d170a1a7 100644 --- a/docs/content/1.guide/1.what-is-a-router.md +++ b/docs/content/1.guide/1.what-is-a-router.md @@ -4,7 +4,9 @@ Routers are the core primitive of Vinxi. A router is a specification for how a group of routes should be handled. Lets take a look at the different parts of a router. -## `name` +## Common Options + +### `name` ::list @@ -15,7 +17,7 @@ A router is a specification for how a group of routes should be handled. Lets ta - The name of the router that the code is currently executing in is available as `import.meta.env.ROUTER_NAME`. :: -## `base` +### `base` ::list @@ -24,7 +26,15 @@ A router is a specification for how a group of routes should be handled. Lets ta - The base path is available as `import.meta.env.BASE_URL`. :: -## `mode` +### `mode` + +::list +- The mode of the router. +- Determines how the other parts of the router are interpreted. +- The mode is available as `import.meta.env.ROUTER_MODE`. +:: + +### `routes` ::list - The mode of the router. @@ -32,9 +42,26 @@ A router is a specification for how a group of routes should be handled. Lets ta - The mode is available as `import.meta.env.ROUTER_MODE`. :: +### `target` + +::list +- Target platform for the router. +- Available targets are: `"browser"`, `"server"` +:: + +### `plugins` +::list +:: + +### `outDir` + +::list +- The output directory for the router. +:: + > Vinxi supports a few router modes out of the box: `"static"`, `"handler"`, `"build"`, `"spa"`. New modes can be added by you too. Lets see how each mode is different? -### `mode: "static"` +## `mode: "static"` ::list - A simple static router that serves files from the `fs.dir` directory at the `base` path. @@ -57,7 +84,10 @@ export default createApp({ }); ``` -### `mode: "handler"` +### `dir` + + +## `mode: "handler"` ::list - A router typically targetting the server. @@ -82,7 +112,24 @@ export default createApp({ ] }); ``` -### `mode: "build"` + +### `handler` + +::list +- The mode of the router. +- Determines how the other parts of the router are interpreted. +- The mode is available as `import.meta.env.ROUTER_MODE`. +:: + +### `middleware` + +::list +- The mode of the router. +- Determines how the other parts of the router are interpreted. +- The mode is available as `import.meta.env.ROUTER_MODE`. +:: + +## mode: `"build"` ::list - A build router serves the compiled handler and subroutes as static assets. @@ -115,15 +162,15 @@ export default createApp({ - Use the handler from this router as the `src` to render a script tag in the SSR response. :: + + ```ts const clientManifest = import.meta.env.MANIFEST["client"]; const scriptSrc = clientManifest.inputs[clientManifest.handler]; const scriptTag = ``; ``` -### `mode: "spa"` - -## `handler` +### `handler` ::list - The mode of the router. @@ -131,21 +178,13 @@ const scriptTag = ``; - The mode is available as `import.meta.env.ROUTER_MODE`. :: -## `routes` + +## mode: `"spa"` + +### `handler` ::list - The mode of the router. - Determines how the other parts of the router are interpreted. - The mode is available as `import.meta.env.ROUTER_MODE`. -:: - -## `target` - -::list -- Target platform for the router. -- Available targets are: `"browser"`, `"server"` -:: - -## `plugins` -::list -:: +:: \ No newline at end of file