Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/travis-r6s/nitro-vite
A simple demo to show how Nitro + Vite can be used together as an MPA.
https://github.com/travis-r6s/nitro-vite
azure-functions nitro unjs vite
Last synced: 16 days ago
JSON representation
A simple demo to show how Nitro + Vite can be used together as an MPA.
- Host: GitHub
- URL: https://github.com/travis-r6s/nitro-vite
- Owner: travis-r6s
- Created: 2024-01-17T12:08:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-26T14:00:06.000Z (12 months ago)
- Last Synced: 2024-01-26T15:24:32.674Z (12 months ago)
- Topics: azure-functions, nitro, unjs, vite
- Language: TypeScript
- Homepage: https://brave-dune-045f79d0f.4.azurestaticapps.net
- Size: 95.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nitro + Vite Minimal Starter
[Demo Site](https://brave-dune-045f79d0f.4.azurestaticapps.net)
> Note: There is a project called [Vinxi](https://github.com/nksaraf/vinxi) which turns all this into an actual framework you could (and probably should) use instead. It also enables you to do SSR 👀
A simple demo to show how Nitro + Vite can be used together as an MPA. This means you can have Nitro serve both your API (with routes under the `/routes/*` folder), and your SPA (code located in `/app`, and rendered by the `./renderer.ts` handler), and build this for any hosting platform.
I built this as a POC to see if I could create an MPA for Azure Static Web Apps - I wanted to create a Shopify app which had some middleware to check if the current user is authenticated on their first visit to `/`. With Nitro, I can run this middleware check, and a function either redirects to another API route `/login`, or renders the HTML for the index page, and the browser then loads the assets from the public directory.
## Setup
Make sure to install the dependencies:
```bash
pnpm install
```## Development Server
Start the development server on
```bash
pnpm run dev
```## Production
Build the application for production:
```bash
pnpm run build
```Locally preview production build:
```bash
pnpm run preview
```Check out the [deployment documentation](https://nitro.unjs.io/deploy) for more information.