Vinxi

The Full Stack JavaScript SDK

README

vinxi


Compose full stack applications (and frameworks) using [Vite](https://github.com/vitejs/vite), the versatile bundler and dev server, and [Nitro](https://github.com/unjs/nitro), the universal production server. The core primitive in vinxi is a router.

Inspired by the Bun.App API.

- Routers are handlers that tell us how specific URLs should be handled. We support various router modes: "static", "spa", "http", (and new ones can be added). Routers specify the handler file (entrypoint) to use for their base-prefixed routes. They can also specify a dir and style in some router modes to include a file system router that is provided to the handler. Routers specify their bundler configuration, via the build property. The routers tell the bundler what entry points to build, what vite plugins to use, etc.

Goals


Primary goal is to build the tools needed to build a NextJS or SolidStart style metaframework on top of vite without worrying about a lot of the wiring required to keep dev and prod working along with SSR, SPA, RSC, and all the other acronyms. etc. On top of that, we should be able to deploy anywhere easily.

Mostly trying to disappear for the user outside the app.js file

The surface layer we are intending to tackle:
1. Full stack builds (handle manifest stuff to figure out what assets to load at prod runtime)
2. Dev time asset handling (avoiding FOUC in SSR frameworks) and smoothing over some of vite's dev/prod mismatching behaviours by providing common manifest APIs that work in dev and prod the same way
3. File system router (not any specific file system conventions, just an API for interfacing with FileSystemRouters and utils to implement your conventions in them)
4. Building the server, and providing a simple opaque handler API to control the server
5. Adapter stuff to deploy to various platforms with support for all the features they provide
6. Not to abstract away the platforms. Let people use what they want to the fullest
7. Have little opinion about how the app should be authored or structured

Roadmap


- [ ] vinxi deploy
- [x] hooks throughout the app licycle:
- dev: app:created, app:started, router:created

Try it out


  1. ```bash
  2. npm install vinxi
  3. ```

React SSR


  1. ```ts
  2. import reactRefresh from "@vitejs/plugin-react";
  3. import { createApp } from "vinxi";

  4. export default createApp({
  5. routers: [
  6.   {
  7.    name: "public",
  8.    type: "static",
  9.    dir: "./public",
  10.   },
  11.   {
  12.    name: "client",
  13.    type: "client",
  14.    handler: "./app/client.tsx",
  15.    target: "browser",
  16.    plugins: () => [reactRefresh()],
  17.    base: "/_build",
  18.   },
  19.   {
  20.    name: "ssr",
  21.    type: "http",
  22.    handler: "./app/server.tsx",
  23.    target: "server",
  24.   },
  25. ],
  26. });
  27. ```

Solid SSR


  1. ```ts
  2. import { createApp } from "vinxi";
  3. import solid from "vite-plugin-solid";

  4. export default createApp({
  5. routers: [
  6.   {
  7.    name: "public",
  8.    type: "static",
  9.    dir: "./public",
  10.   },
  11.   {
  12.    name: "client",
  13.    type: "client",
  14.    handler: "./app/client.tsx",
  15.    target: "browser",
  16.    plugins: () => [solid({ ssr: true })],
  17.    base: "/_build",
  18.   },
  19.   {
  20.    name: "ssr",
  21.    type: "http",
  22.    handler: "./app/server.tsx",
  23.    target: "server",
  24.    plugins: () => [solid({ ssr: true })],
  25.   },
  26. ],
  27. });
  28. ```