Skip to content

Commit d86cbbc

Browse files
committed
update tanstack start
1 parent a4be7f6 commit d86cbbc

File tree

8 files changed

+1936
-266
lines changed

8 files changed

+1936
-266
lines changed

apps/docs/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
"@sanity/image-url": "^1.2.0",
3232
"@sanity/table": "2.0.0",
3333
"@sanity/vision": "4.11.0",
34+
"@tanstack/nitro-v2-vite-plugin": "1.133.19",
3435
"@tanstack/react-router": "1.133.32",
3536
"@tanstack/react-start": "1.133.32",
37+
"@vitejs/plugin-react": "5.1.0",
3638
"cva": "1.0.0-beta.4",
3739
"groq": "4.11.0",
3840
"prism-react-renderer": "2.4.1",

apps/docs/src/routeTree.gen.ts

Lines changed: 56 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@
88
// You should NOT make any changes in this file as it will be overwritten.
99
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
1010

11-
import { createServerRootRoute } from '@tanstack/react-start/server'
12-
1311
import { Route as rootRouteImport } from './routes/__root'
1412
import { Route as DocsRouteImport } from './routes/_docs'
1513
import { Route as DocsIndexRouteImport } from './routes/_docs/index'
1614
import { Route as StudioSplatRouteImport } from './routes/studio/$'
15+
import { Route as ApiHealthRouteImport } from './routes/api/health'
1716
import { Route as DocsSlugRouteImport } from './routes/_docs/$slug'
1817
import { Route as DocsProfilIndexRouteImport } from './routes/_docs/profil/index'
1918
import { Route as DocsKomponenterIndexRouteImport } from './routes/_docs/komponenter/index'
2019
import { Route as DocsProfilIkonerRouteImport } from './routes/_docs/profil/ikoner'
2120
import { Route as DocsProfilFargerRouteImport } from './routes/_docs/profil/farger'
2221
import { Route as DocsKomponenterSlugRouteImport } from './routes/_docs/komponenter/$slug'
23-
import { ServerRoute as ApiHealthServerRouteImport } from './routes/api/health'
24-
25-
const rootServerRouteImport = createServerRootRoute()
2622

2723
const DocsRoute = DocsRouteImport.update({
2824
id: '/_docs',
@@ -38,6 +34,11 @@ const StudioSplatRoute = StudioSplatRouteImport.update({
3834
path: '/studio/$',
3935
getParentRoute: () => rootRouteImport,
4036
} as any)
37+
const ApiHealthRoute = ApiHealthRouteImport.update({
38+
id: '/api/health',
39+
path: '/api/health',
40+
getParentRoute: () => rootRouteImport,
41+
} as any)
4142
const DocsSlugRoute = DocsSlugRouteImport.update({
4243
id: '/$slug',
4344
path: '/$slug',
@@ -68,15 +69,10 @@ const DocsKomponenterSlugRoute = DocsKomponenterSlugRouteImport.update({
6869
path: '/komponenter/$slug',
6970
getParentRoute: () => DocsRoute,
7071
} as any)
71-
const ApiHealthServerRoute = ApiHealthServerRouteImport.update({
72-
id: '/api/health',
73-
path: '/api/health',
74-
getParentRoute: () => rootServerRouteImport,
75-
} as any)
7672

7773
export interface FileRoutesByFullPath {
78-
'': typeof DocsRouteWithChildren
7974
'/$slug': typeof DocsSlugRoute
75+
'/api/health': typeof ApiHealthRoute
8076
'/studio/$': typeof StudioSplatRoute
8177
'/': typeof DocsIndexRoute
8278
'/komponenter/$slug': typeof DocsKomponenterSlugRoute
@@ -87,6 +83,7 @@ export interface FileRoutesByFullPath {
8783
}
8884
export interface FileRoutesByTo {
8985
'/$slug': typeof DocsSlugRoute
86+
'/api/health': typeof ApiHealthRoute
9087
'/studio/$': typeof StudioSplatRoute
9188
'/': typeof DocsIndexRoute
9289
'/komponenter/$slug': typeof DocsKomponenterSlugRoute
@@ -99,6 +96,7 @@ export interface FileRoutesById {
9996
__root__: typeof rootRouteImport
10097
'/_docs': typeof DocsRouteWithChildren
10198
'/_docs/$slug': typeof DocsSlugRoute
99+
'/api/health': typeof ApiHealthRoute
102100
'/studio/$': typeof StudioSplatRoute
103101
'/_docs/': typeof DocsIndexRoute
104102
'/_docs/komponenter/$slug': typeof DocsKomponenterSlugRoute
@@ -110,8 +108,8 @@ export interface FileRoutesById {
110108
export interface FileRouteTypes {
111109
fileRoutesByFullPath: FileRoutesByFullPath
112110
fullPaths:
113-
| ''
114111
| '/$slug'
112+
| '/api/health'
115113
| '/studio/$'
116114
| '/'
117115
| '/komponenter/$slug'
@@ -122,6 +120,7 @@ export interface FileRouteTypes {
122120
fileRoutesByTo: FileRoutesByTo
123121
to:
124122
| '/$slug'
123+
| '/api/health'
125124
| '/studio/$'
126125
| '/'
127126
| '/komponenter/$slug'
@@ -133,6 +132,7 @@ export interface FileRouteTypes {
133132
| '__root__'
134133
| '/_docs'
135134
| '/_docs/$slug'
135+
| '/api/health'
136136
| '/studio/$'
137137
| '/_docs/'
138138
| '/_docs/komponenter/$slug'
@@ -144,29 +144,9 @@ export interface FileRouteTypes {
144144
}
145145
export interface RootRouteChildren {
146146
DocsRoute: typeof DocsRouteWithChildren
147+
ApiHealthRoute: typeof ApiHealthRoute
147148
StudioSplatRoute: typeof StudioSplatRoute
148149
}
149-
export interface FileServerRoutesByFullPath {
150-
'/api/health': typeof ApiHealthServerRoute
151-
}
152-
export interface FileServerRoutesByTo {
153-
'/api/health': typeof ApiHealthServerRoute
154-
}
155-
export interface FileServerRoutesById {
156-
__root__: typeof rootServerRouteImport
157-
'/api/health': typeof ApiHealthServerRoute
158-
}
159-
export interface FileServerRouteTypes {
160-
fileServerRoutesByFullPath: FileServerRoutesByFullPath
161-
fullPaths: '/api/health'
162-
fileServerRoutesByTo: FileServerRoutesByTo
163-
to: '/api/health'
164-
id: '__root__' | '/api/health'
165-
fileServerRoutesById: FileServerRoutesById
166-
}
167-
export interface RootServerRouteChildren {
168-
ApiHealthServerRoute: typeof ApiHealthServerRoute
169-
}
170150

171151
declare module '@tanstack/react-router' {
172152
interface FileRoutesByPath {
@@ -177,53 +157,39 @@ declare module '@tanstack/react-router' {
177157
preLoaderRoute: typeof DocsRouteImport
178158
parentRoute: typeof rootRouteImport
179159
}
180-
'/_docs/$slug': {
181-
id: '/_docs/$slug'
182-
path: '/$slug'
183-
fullPath: '/$slug'
184-
preLoaderRoute: typeof DocsSlugRouteImport
160+
'/_docs/': {
161+
id: '/_docs/'
162+
path: '/'
163+
fullPath: '/'
164+
preLoaderRoute: typeof DocsIndexRouteImport
185165
parentRoute: typeof DocsRoute
186166
}
187-
'/api/health': {
188-
id: '/api/health'
189-
path: ''
190-
fullPath: '/api/health'
191-
preLoaderRoute: unknown
192-
parentRoute: typeof rootRouteImport
193-
}
194167
'/studio/$': {
195168
id: '/studio/$'
196169
path: '/studio/$'
197170
fullPath: '/studio/$'
198171
preLoaderRoute: typeof StudioSplatRouteImport
199172
parentRoute: typeof rootRouteImport
200173
}
201-
'/_docs/': {
202-
id: '/_docs/'
203-
path: '/'
204-
fullPath: '/'
205-
preLoaderRoute: typeof DocsIndexRouteImport
206-
parentRoute: typeof DocsRoute
207-
}
208-
'/_docs/komponenter/$slug': {
209-
id: '/_docs/komponenter/$slug'
210-
path: '/komponenter/$slug'
211-
fullPath: '/komponenter/$slug'
212-
preLoaderRoute: typeof DocsKomponenterSlugRouteImport
213-
parentRoute: typeof DocsRoute
174+
'/api/health': {
175+
id: '/api/health'
176+
path: '/api/health'
177+
fullPath: '/api/health'
178+
preLoaderRoute: typeof ApiHealthRouteImport
179+
parentRoute: typeof rootRouteImport
214180
}
215-
'/_docs/profil/farger': {
216-
id: '/_docs/profil/farger'
217-
path: '/profil/farger'
218-
fullPath: '/profil/farger'
219-
preLoaderRoute: typeof DocsProfilFargerRouteImport
181+
'/_docs/$slug': {
182+
id: '/_docs/$slug'
183+
path: '/$slug'
184+
fullPath: '/$slug'
185+
preLoaderRoute: typeof DocsSlugRouteImport
220186
parentRoute: typeof DocsRoute
221187
}
222-
'/_docs/profil/ikoner': {
223-
id: '/_docs/profil/ikoner'
224-
path: '/profil/ikoner'
225-
fullPath: '/profil/ikoner'
226-
preLoaderRoute: typeof DocsProfilIkonerRouteImport
188+
'/_docs/profil/': {
189+
id: '/_docs/profil/'
190+
path: '/profil'
191+
fullPath: '/profil'
192+
preLoaderRoute: typeof DocsProfilIndexRouteImport
227193
parentRoute: typeof DocsRoute
228194
}
229195
'/_docs/komponenter/': {
@@ -233,86 +199,26 @@ declare module '@tanstack/react-router' {
233199
preLoaderRoute: typeof DocsKomponenterIndexRouteImport
234200
parentRoute: typeof DocsRoute
235201
}
236-
'/_docs/profil/': {
237-
id: '/_docs/profil/'
238-
path: '/profil'
239-
fullPath: '/profil'
240-
preLoaderRoute: typeof DocsProfilIndexRouteImport
202+
'/_docs/profil/ikoner': {
203+
id: '/_docs/profil/ikoner'
204+
path: '/profil/ikoner'
205+
fullPath: '/profil/ikoner'
206+
preLoaderRoute: typeof DocsProfilIkonerRouteImport
241207
parentRoute: typeof DocsRoute
242208
}
243-
}
244-
}
245-
declare module '@tanstack/react-start/server' {
246-
interface ServerFileRoutesByPath {
247-
'/_docs': {
248-
id: '/_docs'
249-
path: ''
250-
fullPath: ''
251-
preLoaderRoute: unknown
252-
parentRoute: typeof rootServerRouteImport
253-
}
254-
'/_docs/$slug': {
255-
id: '/_docs/$slug'
256-
path: '/$slug'
257-
fullPath: '/$slug'
258-
preLoaderRoute: unknown
259-
parentRoute: typeof rootServerRouteImport
260-
}
261-
'/api/health': {
262-
id: '/api/health'
263-
path: '/api/health'
264-
fullPath: '/api/health'
265-
preLoaderRoute: typeof ApiHealthServerRouteImport
266-
parentRoute: typeof rootServerRouteImport
267-
}
268-
'/studio/$': {
269-
id: '/studio/$'
270-
path: '/studio/$'
271-
fullPath: '/studio/$'
272-
preLoaderRoute: unknown
273-
parentRoute: typeof rootServerRouteImport
274-
}
275-
'/_docs/': {
276-
id: '/_docs/'
277-
path: '/'
278-
fullPath: '/'
279-
preLoaderRoute: unknown
280-
parentRoute: typeof rootServerRouteImport
281-
}
282-
'/_docs/komponenter/$slug': {
283-
id: '/_docs/komponenter/$slug'
284-
path: '/komponenter/$slug'
285-
fullPath: '/komponenter/$slug'
286-
preLoaderRoute: unknown
287-
parentRoute: typeof rootServerRouteImport
288-
}
289209
'/_docs/profil/farger': {
290210
id: '/_docs/profil/farger'
291211
path: '/profil/farger'
292212
fullPath: '/profil/farger'
293-
preLoaderRoute: unknown
294-
parentRoute: typeof rootServerRouteImport
295-
}
296-
'/_docs/profil/ikoner': {
297-
id: '/_docs/profil/ikoner'
298-
path: '/profil/ikoner'
299-
fullPath: '/profil/ikoner'
300-
preLoaderRoute: unknown
301-
parentRoute: typeof rootServerRouteImport
302-
}
303-
'/_docs/komponenter/': {
304-
id: '/_docs/komponenter/'
305-
path: '/komponenter'
306-
fullPath: '/komponenter'
307-
preLoaderRoute: unknown
308-
parentRoute: typeof rootServerRouteImport
213+
preLoaderRoute: typeof DocsProfilFargerRouteImport
214+
parentRoute: typeof DocsRoute
309215
}
310-
'/_docs/profil/': {
311-
id: '/_docs/profil/'
312-
path: '/profil'
313-
fullPath: '/profil'
314-
preLoaderRoute: unknown
315-
parentRoute: typeof rootServerRouteImport
216+
'/_docs/komponenter/$slug': {
217+
id: '/_docs/komponenter/$slug'
218+
path: '/komponenter/$slug'
219+
fullPath: '/komponenter/$slug'
220+
preLoaderRoute: typeof DocsKomponenterSlugRouteImport
221+
parentRoute: typeof DocsRoute
316222
}
317223
}
318224
}
@@ -341,14 +247,18 @@ const DocsRouteWithChildren = DocsRoute._addFileChildren(DocsRouteChildren)
341247

342248
const rootRouteChildren: RootRouteChildren = {
343249
DocsRoute: DocsRouteWithChildren,
250+
ApiHealthRoute: ApiHealthRoute,
344251
StudioSplatRoute: StudioSplatRoute,
345252
}
346253
export const routeTree = rootRouteImport
347254
._addFileChildren(rootRouteChildren)
348255
._addFileTypes<FileRouteTypes>()
349-
const rootServerRouteChildren: RootServerRouteChildren = {
350-
ApiHealthServerRoute: ApiHealthServerRoute,
256+
257+
import type { getRouter } from './router.tsx'
258+
import type { createStart } from '@tanstack/react-start'
259+
declare module '@tanstack/react-start' {
260+
interface Register {
261+
ssr: true
262+
router: Awaited<ReturnType<typeof getRouter>>
263+
}
351264
}
352-
export const serverRouteTree = rootServerRouteImport
353-
._addFileChildren(rootServerRouteChildren)
354-
._addFileTypes<FileServerRouteTypes>()

apps/docs/src/router.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import { createRouter as createTanStackRouter } from '@tanstack/react-router';
22
import { routeTree } from './routeTree.gen';
33

4-
export function createRouter() {
4+
export function getRouter() {
55
const router = createTanStackRouter({
66
scrollRestoration: true,
77
routeTree,
88
});
99

1010
return router;
1111
}
12-
13-
declare module '@tanstack/react-router' {
14-
interface Register {
15-
router: ReturnType<typeof createRouter>;
16-
}
17-
}

apps/docs/src/routes/_docs/$slug.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { createFileRoute, notFound } from '@tanstack/react-router';
22
import { defineQuery } from 'groq';
33
import { sanityFetch } from '@/lib/sanity';
4-
import { ResourceLink, ResourceLinks } from '@/ui/resource-links';
4+
import {
5+
ResourceLink,
6+
type ResourceLinkProps,
7+
ResourceLinks,
8+
} from '@/ui/resource-links';
59
import { SanityContent } from '@/ui/sanity-content';
610
import { ScrollToTop } from '@/ui/scroll-to-top';
711
import { TableOfContentsNav } from '@/ui/table-of-contents-nav';
@@ -49,7 +53,7 @@ function Page() {
4953
url && (
5054
<ResourceLink
5155
key={_key}
52-
type={linkType}
56+
type={linkType as ResourceLinkProps['type']}
5357
href={url}
5458
text={text}
5559
/>

apps/docs/src/routes/api/health.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { createServerFileRoute } from '@tanstack/react-start/server';
1+
import { createFileRoute } from '@tanstack/react-router';
22

3-
export const ServerRoute = createServerFileRoute('/api/health').methods({
4-
GET: () => {
5-
return new Response('Im alive!');
3+
export const Route = createFileRoute('/api/health')({
4+
server: {
5+
handlers: {
6+
GET: async () => {
7+
return new Response('Im alive!');
8+
},
9+
},
610
},
711
});

0 commit comments

Comments
 (0)