-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
4,644 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ | |
"@apollo/experimental-nextjs-app-support": "exec:./shared/build-experimental-nextjs-app-support.cjs", | ||
"@apollo/client-integration-react-router": "exec:./shared/build-client-integration-react-router.cjs", | ||
"graphql": "17.0.0-alpha.2", | ||
"turbo-stream": "npm:@phryneas/[email protected]" | ||
"turbo-stream": "npm:@phryneas/[email protected]", | ||
"@tanstack/react-router": "patch:@tanstack/react-router@npm%3A1.91.3#~/../.yarn/patches/@tanstack-react-router-npm-1.91.3-8e077b923e.patch", | ||
"@tanstack/start": "patch:@tanstack/start@npm%3A1.91.3#~/../.yarn/patches/@tanstack-start-npm-1.91.3-de6292cf0b.patch" | ||
}, | ||
"workspaces": [ | ||
"*" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { defineConfig } from "@tanstack/start/config"; | ||
|
||
export default defineConfig({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// <reference types="vinxi/types/client" /> | ||
import { hydrateRoot } from "react-dom/client"; | ||
import { StartClient } from "@tanstack/start"; | ||
import { createRouter } from "./router"; | ||
|
||
const router = createRouter(); | ||
|
||
hydrateRoot(document, <StartClient router={router} />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* eslint-disable */ | ||
|
||
// @ts-nocheck | ||
|
||
// noinspection JSUnusedGlobalSymbols | ||
|
||
// This file was automatically generated by TanStack Router. | ||
// You should NOT make any changes in this file as it will be overwritten. | ||
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. | ||
|
||
// Import Routes | ||
|
||
import { Route as rootRoute } from './routes/__root' | ||
import { Route as IndexImport } from './routes/index' | ||
|
||
// Create/Update Routes | ||
|
||
const IndexRoute = IndexImport.update({ | ||
id: '/', | ||
path: '/', | ||
getParentRoute: () => rootRoute, | ||
} as any) | ||
|
||
// Populate the FileRoutesByPath interface | ||
|
||
declare module '@tanstack/react-router' { | ||
interface FileRoutesByPath { | ||
'/': { | ||
id: '/' | ||
path: '/' | ||
fullPath: '/' | ||
preLoaderRoute: typeof IndexImport | ||
parentRoute: typeof rootRoute | ||
} | ||
} | ||
} | ||
|
||
// Create and export the route tree | ||
|
||
export interface FileRoutesByFullPath { | ||
'/': typeof IndexRoute | ||
} | ||
|
||
export interface FileRoutesByTo { | ||
'/': typeof IndexRoute | ||
} | ||
|
||
export interface FileRoutesById { | ||
__root__: typeof rootRoute | ||
'/': typeof IndexRoute | ||
} | ||
|
||
export interface FileRouteTypes { | ||
fileRoutesByFullPath: FileRoutesByFullPath | ||
fullPaths: '/' | ||
fileRoutesByTo: FileRoutesByTo | ||
to: '/' | ||
id: '__root__' | '/' | ||
fileRoutesById: FileRoutesById | ||
} | ||
|
||
export interface RootRouteChildren { | ||
IndexRoute: typeof IndexRoute | ||
} | ||
|
||
const rootRouteChildren: RootRouteChildren = { | ||
IndexRoute: IndexRoute, | ||
} | ||
|
||
export const routeTree = rootRoute | ||
._addFileChildren(rootRouteChildren) | ||
._addFileTypes<FileRouteTypes>() | ||
|
||
/* ROUTE_MANIFEST_START | ||
{ | ||
"routes": { | ||
"__root__": { | ||
"filePath": "__root.tsx", | ||
"children": [ | ||
"/" | ||
] | ||
}, | ||
"/": { | ||
"filePath": "index.tsx" | ||
} | ||
} | ||
} | ||
ROUTE_MANIFEST_END */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createRouter as createTanStackRouter } from "@tanstack/react-router"; | ||
import { routeTree } from "./routeTree.gen"; | ||
|
||
export function createRouter() { | ||
const router = createTanStackRouter({ | ||
routeTree, | ||
}); | ||
|
||
return router; | ||
} | ||
|
||
declare module "@tanstack/react-router" { | ||
interface Register { | ||
router: ReturnType<typeof createRouter>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { | ||
Outlet, | ||
ScrollRestoration, | ||
createRootRoute, | ||
} from "@tanstack/react-router"; | ||
import { Meta, Scripts } from "@tanstack/start"; | ||
import type { ReactNode } from "react"; | ||
|
||
export const Route = createRootRoute({ | ||
head: () => ({ | ||
meta: [ | ||
{ | ||
charSet: "utf-8", | ||
}, | ||
{ | ||
name: "viewport", | ||
content: "width=device-width, initial-scale=1", | ||
}, | ||
{ | ||
title: "TanStack Start Starter", | ||
}, | ||
], | ||
}), | ||
component: RootComponent, | ||
}); | ||
|
||
function RootComponent() { | ||
return ( | ||
<RootDocument> | ||
<Outlet /> | ||
</RootDocument> | ||
); | ||
} | ||
|
||
function RootDocument({ children }: Readonly<{ children: ReactNode }>) { | ||
return ( | ||
<html> | ||
<head> | ||
<Meta /> | ||
</head> | ||
<body> | ||
{children} | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as fs from "node:fs"; | ||
import { createFileRoute, useRouter } from "@tanstack/react-router"; | ||
import { createServerFn } from "@tanstack/start"; | ||
|
||
const filePath = "count.txt"; | ||
|
||
async function readCount() { | ||
return parseInt( | ||
await fs.promises.readFile(filePath, "utf-8").catch(() => "0") | ||
); | ||
} | ||
|
||
const getCount = createServerFn({ | ||
method: "GET", | ||
}).handler(() => { | ||
return readCount(); | ||
}); | ||
|
||
const updateCount = createServerFn({ method: "POST" }) | ||
.validator((d: number) => d) | ||
.handler(async ({ data }) => { | ||
const count = await readCount(); | ||
await fs.promises.writeFile(filePath, `${count + data}`); | ||
}); | ||
|
||
export const Route = createFileRoute("/")({ | ||
component: Home, | ||
loader: async () => await getCount(), | ||
}); | ||
|
||
function Home() { | ||
const router = useRouter(); | ||
const state = Route.useLoaderData(); | ||
|
||
return ( | ||
<button | ||
type="button" | ||
onClick={() => { | ||
updateCount({ data: 1 }).then(() => { | ||
router.invalidate(); | ||
}); | ||
}} | ||
> | ||
Add 1 to {state}? | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/// <reference types="vinxi/types/server" /> | ||
import { | ||
createStartHandler, | ||
defaultStreamHandler, | ||
} from "@tanstack/start/server"; | ||
import { getRouterManifest } from "@tanstack/start/router-manifest"; | ||
|
||
import { createRouter } from "./router"; | ||
|
||
export default createStartHandler({ | ||
createRouter, | ||
getRouterManifest, | ||
})(defaultStreamHandler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "tanstack-start", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vinxi dev", | ||
"build": "vinxi build", | ||
"start": "vinxi start" | ||
}, | ||
"dependencies": { | ||
"@tanstack/react-router": "1.91.3", | ||
"@tanstack/start": "1.91.3", | ||
"react": "^19.0.0", | ||
"react-dom": "^19.0.0", | ||
"vinxi": "^0.5.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^19.0.2", | ||
"@types/react-dom": "^19.0.2", | ||
"@vitejs/plugin-react": "^4.3.4", | ||
"typescript": "^5.7.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"moduleResolution": "Bundler", | ||
"module": "ESNext", | ||
"target": "ES2022", | ||
"skipLibCheck": true, | ||
"strictNullChecks": true, | ||
}, | ||
} |
Oops, something went wrong.