Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @pi0
15 changes: 15 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: autofix.ci
on: { push: {}, pull_request: {} }
permissions: { contents: read }
jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- run: npm i -fg corepack && corepack enable
- uses: actions/setup-node@v5
with: { node-version: lts/*, cache: pnpm }
- run: pnpm install
- run: pnpm lint:fix
- uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27
with: { commit-message: "chore: apply automated updates" }
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ci

on:
push: { branches: [main] }
pull_request: { branches: [main] }

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- run: npm i -g --force corepack && corepack enable
- uses: actions/setup-node@v5
with: { node-version: lts/*, cache: pnpm }
- run: pnpm install
- run: pnpm lint
- run: pnpm vitest
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

| Example | Source | Playground | Clone |
| ----------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `basic-service` | [examples/basic-service](./examples/basic-service/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/basic-service?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/basic-service basic-service-app` |
| `h3` | [examples/h3](./examples/h3/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/h3?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/h3 h3-app` |
| `hono` | [examples/hono](./examples/hono/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/hono?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/hono hono-app` |
| `node-compat` | [examples/node-compat](./examples/node-compat/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/node-compat?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/node-compat node-compat-app` |
| `qwik` | [examples/qwik](./examples/qwik/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/qwik?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/qwik qwik-app` |
| `react-ssr` | [examples/react-ssr](./examples/react-ssr/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/react-ssr?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/react-ssr react-ssr-app` |
| `solid-ssr` | [examples/solid-ssr](./examples/solid-ssr/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/solid-ssr?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/solid-ssr solid-ssr-app` |
| `standard` | [examples/standard](./examples/standard/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/standard?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/standard standard-app` |
| `tanstack-router-react` | [examples/tanstack-router-react](./examples/tanstack-router-react/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/tanstack-router-react?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/tanstack-router-react tanstack-router-react-app` |
| `tanstack-start-react` | [examples/tanstack-start-react](./examples/tanstack-start-react/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/tanstack-start-react?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/tanstack-start-react tanstack-start-react-app` |
| `vue-ssr` | [examples/vue-ssr](./examples/vue-ssr/) | [stackblitz](https://stackblitz.com/fork/github/nitrojs/nitro-vite-examples/tree/main/examples/vue-ssr?startScript=dev&file=vite.config.mjs,server.ts) | `npx giget gh:nitrojs/vite-examples/examples/vue-ssr vue-ssr-app` |
Expand Down
5 changes: 0 additions & 5 deletions examples/basic-service/server.ts

This file was deleted.

2 changes: 1 addition & 1 deletion examples/h3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"devDependencies": {
"h3": "npm:[email protected]",
"nitro": "npm:[email protected]20251013-195204-b3acfd09",
"nitro": "npm:[email protected]20251015-103211-44b2f091",
"vite": "^7.1.10"
}
}
4 changes: 3 additions & 1 deletion examples/h3/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { H3 } from "h3";

const app = new H3().get("/**", () => "⚡️ Hello from H3!");
const app = new H3()
.get("/api/hello", () => "API Works!")
.get("/", () => "⚡️ Hello from H3!");

export default app;
2 changes: 1 addition & 1 deletion examples/hono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"devDependencies": {
"hono": "^4.9.12",
"nitro": "npm:[email protected]20251013-195204-b3acfd09",
"nitro": "npm:[email protected]20251015-103211-44b2f091",
"vite": "^7.1.10"
}
}
4 changes: 3 additions & 1 deletion examples/hono/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Hono } from "hono";

const app = new Hono();

app.get("/*", (c) => c.text("🔥 Hello from Hono!"));
app.get("/", (c) => c.text("🔥 Hello from Hono!"));

app.get("/api/hello", (c) => c.text("API Works!"));

export default app;
2 changes: 1 addition & 1 deletion examples/node-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev"
},
"devDependencies": {
"nitro": "npm:[email protected]20251013-195204-b3acfd09",
"nitro": "npm:[email protected]20251015-103211-44b2f091",
"vite": "^7.1.10"
},
"dependencies": {
Expand Down
21 changes: 15 additions & 6 deletions examples/node-compat/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ import type { IncomingMessage, ServerResponse } from "node:http";
import { toReqRes, toFetchResponse } from "fetch-to-node";

const nodeHandler = (req: IncomingMessage, res: ServerResponse) => {
setImmediate(() => {
if (req.url === "/api/hello") {
res.end("API Works!");
return;
}
if (req.url === "/") {
res.end("🟢 Hello from Node.js handler!");
});
return;
}
res.statusCode = 404;
res.end("Not Found");
};

export const fetch = async (webReq: Request) => {
const { req, res } = toReqRes(webReq);
nodeHandler(req as IncomingMessage, res as ServerResponse);
return toFetchResponse(res as ServerResponse);
export default {
fetch: async (webReq: Request) => {
const { req, res } = toReqRes(webReq);
nodeHandler(req as IncomingMessage, res as ServerResponse);
return toFetchResponse(res as ServerResponse);
},
};
1 change: 1 addition & 0 deletions examples/react-ssr/api/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => "API Works!";
2 changes: 1 addition & 1 deletion examples/react-ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@vitejs/plugin-react": "^5.0.4",
"nitro": "npm:[email protected]20251013-195204-b3acfd09",
"nitro": "npm:[email protected]20251015-103211-44b2f091",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-refresh": "^0.18.0",
Expand Down
1 change: 1 addition & 0 deletions examples/solid-ssr/api/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => "API Works!";
2 changes: 1 addition & 1 deletion examples/solid-ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev"
},
"devDependencies": {
"nitro": "npm:[email protected]20251013-195204-b3acfd09",
"nitro": "npm:[email protected]20251015-103211-44b2f091",
"solid-js": "^1.9.9",
"vite": "^7.1.10",
"vite-plugin-solid": "^2.11.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev"
},
"devDependencies": {
"nitro": "npm:[email protected]20251013-195204-b3acfd09",
"nitro": "npm:[email protected]20251015-103211-44b2f091",
"vite": "^7.1.10"
}
}
11 changes: 11 additions & 0 deletions examples/standard/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
fetch: (req: Request) => {
const url = new URL(req.url);
if (url.pathname === "/api/hello") {
return new Response("API Works!");
}
if (url.pathname === "/") {
return new Response("Hello World!");
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ import { defineConfig } from "vite";
import { nitro } from "nitro/vite";

export default defineConfig({
plugins: [
nitro({
services: { ssr: { entry: "./server.ts" } },
}),
],
plugins: [nitro()],
});
1 change: 1 addition & 0 deletions examples/tanstack-router-react/api/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => "API Works!";
2 changes: 1 addition & 1 deletion examples/tanstack-router-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@vitejs/plugin-react": "^5.0.4",
"nitro": "npm:[email protected]20251013-195204-b3acfd09",
"nitro": "npm:[email protected]20251015-103211-44b2f091",
"vite": "^7.1.10"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion examples/tanstack-router-react/routes/api/hello.ts

This file was deleted.

3 changes: 0 additions & 3 deletions examples/tanstack-router-react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@ export default defineConfig({
react(),
nitro(),
],
nitro: {
preset: "standard",
},
});
12 changes: 12 additions & 0 deletions examples/tanstack-start-react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
count.txt
.env
.nitro
.tanstack
.output
.vinxi
todos.json
1 change: 1 addition & 0 deletions examples/tanstack-start-react/api/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => "API Works!";
11 changes: 5 additions & 6 deletions examples/tanstack-start-react/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{
"name": "tanstack-start-react-example",
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite dev"
"dev": "vite dev",
"serve": "vite preview"
},
"devDependencies": {
"@tanstack/react-router": "^1.132.47",
"@tanstack/react-router-devtools": "^1.133.1",
"@tanstack/react-start": "^1.133.2",
"@types/node": "^24.7.2",
"@types/node": "^22.18.10",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@vitejs/plugin-react": "^4.7.0",
"nitro": "npm:[email protected]20251013-195204-b3acfd09",
"@vitejs/plugin-react": "^5.0.4",
"nitro": "npm:[email protected]20251015-103211-44b2f091",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"typescript": "^5.9.3",
Expand Down
Binary file not shown.
21 changes: 0 additions & 21 deletions examples/tanstack-start-react/src/components/Counter.css

This file was deleted.

15 changes: 0 additions & 15 deletions examples/tanstack-start-react/src/components/Counter.tsx

This file was deleted.

33 changes: 12 additions & 21 deletions examples/tanstack-start-react/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.

import { Route as rootRouteImport } from './routes/__root'
import { Route as AboutRouteImport } from './routes/about'
import { Route as IndexRouteImport } from './routes/index'

const AboutRoute = AboutRouteImport.update({
id: '/about',
path: '/about',
getParentRoute: () => rootRouteImport,
} as any)
const IndexRoute = IndexRouteImport.update({
id: '/',
path: '/',
Expand All @@ -25,39 +19,28 @@ const IndexRoute = IndexRouteImport.update({

export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/about': typeof AboutRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/about': typeof AboutRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/about': typeof AboutRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: '/' | '/about'
fullPaths: '/'
fileRoutesByTo: FileRoutesByTo
to: '/' | '/about'
id: '__root__' | '/' | '/about'
to: '/'
id: '__root__' | '/'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
AboutRoute: typeof AboutRoute
}

declare module '@tanstack/react-router' {
interface FileRoutesByPath {
'/about': {
id: '/about'
path: '/about'
fullPath: '/about'
preLoaderRoute: typeof AboutRouteImport
parentRoute: typeof rootRouteImport
}
'/': {
id: '/'
path: '/'
Expand All @@ -70,8 +53,16 @@ declare module '@tanstack/react-router' {

const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
AboutRoute: AboutRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
23 changes: 8 additions & 15 deletions examples/tanstack-start-react/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import { createRouter as createTanStackRouter } from "@tanstack/react-router";
import { createRouter } from "@tanstack/react-router";

// Import the generated route tree
import { routeTree } from "./routeTree.gen";

export function createRouter() {
const router = createTanStackRouter({
// Create a new router instance
export const getRouter = () => {
return createRouter({
routeTree,
defaultPreload: "intent",
defaultErrorComponent: (err) => <p>{err.error.stack}</p>,
defaultNotFoundComponent: () => <p>not found</p>,
scrollRestoration: true,
defaultPreloadStaleTime: 0,
});

return router;
}

declare module "@tanstack/react-router" {
interface Register {
router: ReturnType<typeof createRouter>;
}
}
};
Loading