Skip to content

Commit

Permalink
Merge branch 'main' into windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Sep 25, 2023
2 parents d3b8eed + 9e6c07b commit cf81fea
Showing 1 changed file with 61 additions and 22 deletions.
83 changes: 61 additions & 22 deletions docs/content/1.guide/1.what-is-a-router.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -24,17 +26,42 @@ 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.
- 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
::

### `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.
Expand All @@ -57,7 +84,10 @@ export default createApp({
});
```

### `mode: "handler"`
### `dir`


## `mode: "handler"`

::list
- A router typically targetting the server.
Expand All @@ -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.
Expand Down Expand Up @@ -115,37 +162,29 @@ 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 = `<script src="${scriptSrc}"></script>`;
```

### `mode: "spa"`

## `handler`
### `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`.
::

## `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
::
::

0 comments on commit cf81fea

Please sign in to comment.