Skip to content

Commit f9c343e

Browse files
chore(examples): add TanStack Start WorkOS example (#3966)
Co-authored-by: SeanCassiere <[email protected]>
1 parent 09e8744 commit f9c343e

30 files changed

+4523
-1405
lines changed

docs/start/config.json

+4
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@
185185
"label": "Trellaux",
186186
"to": "framework/react/examples/start-trellaux"
187187
},
188+
{
189+
"label": "WorkOS",
190+
"to": "framework/react/examples/start-workos"
191+
},
188192
{
189193
"label": "Material UI",
190194
"to": "framework/react/examples/start-material-ui"

docs/start/framework/react/quick-start.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ TanStack Start has load of examples to get you started. Pick one of the examples
3030
- [Convex + Trellaux](../examples/start-convex-trellaux) (start-convex-trellaux)
3131
- [Supabase](../examples/start-supabase-basic) (start-supabase-basic)
3232
- [Trellaux](../examples/start-trellaux) (start-trellaux)
33+
- [WorkOS](../examples/start-workos) (start-workos)
3334
- [Material UI](../examples/start-material-ui) (start-material-ui)
3435

3536
### Stackblitz

examples/react/start-basic/src/routeTree.gen.ts

+92-88
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// Import Routes
1212

1313
import { Route as rootRoute } from './routes/__root'
14-
import { Route as UsersImport } from './routes/users'
1514
import { Route as RedirectImport } from './routes/redirect'
16-
import { Route as PostsImport } from './routes/posts'
1715
import { Route as DeferredImport } from './routes/deferred'
1816
import { Route as PathlessLayoutImport } from './routes/_pathlessLayout'
17+
import { Route as UsersRouteImport } from './routes/users.route'
18+
import { Route as PostsRouteImport } from './routes/posts.route'
1919
import { Route as IndexImport } from './routes/index'
2020
import { Route as UsersIndexImport } from './routes/users.index'
2121
import { Route as PostsIndexImport } from './routes/posts.index'
@@ -28,24 +28,12 @@ import { Route as PathlessLayoutNestedLayoutRouteAImport } from './routes/_pathl
2828

2929
// Create/Update Routes
3030

31-
const UsersRoute = UsersImport.update({
32-
id: '/users',
33-
path: '/users',
34-
getParentRoute: () => rootRoute,
35-
} as any)
36-
3731
const RedirectRoute = RedirectImport.update({
3832
id: '/redirect',
3933
path: '/redirect',
4034
getParentRoute: () => rootRoute,
4135
} as any)
4236

43-
const PostsRoute = PostsImport.update({
44-
id: '/posts',
45-
path: '/posts',
46-
getParentRoute: () => rootRoute,
47-
} as any)
48-
4937
const DeferredRoute = DeferredImport.update({
5038
id: '/deferred',
5139
path: '/deferred',
@@ -57,6 +45,18 @@ const PathlessLayoutRoute = PathlessLayoutImport.update({
5745
getParentRoute: () => rootRoute,
5846
} as any)
5947

48+
const UsersRouteRoute = UsersRouteImport.update({
49+
id: '/users',
50+
path: '/users',
51+
getParentRoute: () => rootRoute,
52+
} as any)
53+
54+
const PostsRouteRoute = PostsRouteImport.update({
55+
id: '/posts',
56+
path: '/posts',
57+
getParentRoute: () => rootRoute,
58+
} as any)
59+
6060
const IndexRoute = IndexImport.update({
6161
id: '/',
6262
path: '/',
@@ -66,25 +66,25 @@ const IndexRoute = IndexImport.update({
6666
const UsersIndexRoute = UsersIndexImport.update({
6767
id: '/',
6868
path: '/',
69-
getParentRoute: () => UsersRoute,
69+
getParentRoute: () => UsersRouteRoute,
7070
} as any)
7171

7272
const PostsIndexRoute = PostsIndexImport.update({
7373
id: '/',
7474
path: '/',
75-
getParentRoute: () => PostsRoute,
75+
getParentRoute: () => PostsRouteRoute,
7676
} as any)
7777

7878
const UsersUserIdRoute = UsersUserIdImport.update({
7979
id: '/$userId',
8080
path: '/$userId',
81-
getParentRoute: () => UsersRoute,
81+
getParentRoute: () => UsersRouteRoute,
8282
} as any)
8383

8484
const PostsPostIdRoute = PostsPostIdImport.update({
8585
id: '/$postId',
8686
path: '/$postId',
87-
getParentRoute: () => PostsRoute,
87+
getParentRoute: () => PostsRouteRoute,
8888
} as any)
8989

9090
const PathlessLayoutNestedLayoutRoute = PathlessLayoutNestedLayoutImport.update(
@@ -125,6 +125,20 @@ declare module '@tanstack/react-router' {
125125
preLoaderRoute: typeof IndexImport
126126
parentRoute: typeof rootRoute
127127
}
128+
'/posts': {
129+
id: '/posts'
130+
path: '/posts'
131+
fullPath: '/posts'
132+
preLoaderRoute: typeof PostsRouteImport
133+
parentRoute: typeof rootRoute
134+
}
135+
'/users': {
136+
id: '/users'
137+
path: '/users'
138+
fullPath: '/users'
139+
preLoaderRoute: typeof UsersRouteImport
140+
parentRoute: typeof rootRoute
141+
}
128142
'/_pathlessLayout': {
129143
id: '/_pathlessLayout'
130144
path: ''
@@ -139,27 +153,13 @@ declare module '@tanstack/react-router' {
139153
preLoaderRoute: typeof DeferredImport
140154
parentRoute: typeof rootRoute
141155
}
142-
'/posts': {
143-
id: '/posts'
144-
path: '/posts'
145-
fullPath: '/posts'
146-
preLoaderRoute: typeof PostsImport
147-
parentRoute: typeof rootRoute
148-
}
149156
'/redirect': {
150157
id: '/redirect'
151158
path: '/redirect'
152159
fullPath: '/redirect'
153160
preLoaderRoute: typeof RedirectImport
154161
parentRoute: typeof rootRoute
155162
}
156-
'/users': {
157-
id: '/users'
158-
path: '/users'
159-
fullPath: '/users'
160-
preLoaderRoute: typeof UsersImport
161-
parentRoute: typeof rootRoute
162-
}
163163
'/_pathlessLayout/_nested-layout': {
164164
id: '/_pathlessLayout/_nested-layout'
165165
path: ''
@@ -172,28 +172,28 @@ declare module '@tanstack/react-router' {
172172
path: '/$postId'
173173
fullPath: '/posts/$postId'
174174
preLoaderRoute: typeof PostsPostIdImport
175-
parentRoute: typeof PostsImport
175+
parentRoute: typeof PostsRouteImport
176176
}
177177
'/users/$userId': {
178178
id: '/users/$userId'
179179
path: '/$userId'
180180
fullPath: '/users/$userId'
181181
preLoaderRoute: typeof UsersUserIdImport
182-
parentRoute: typeof UsersImport
182+
parentRoute: typeof UsersRouteImport
183183
}
184184
'/posts/': {
185185
id: '/posts/'
186186
path: '/'
187187
fullPath: '/posts/'
188188
preLoaderRoute: typeof PostsIndexImport
189-
parentRoute: typeof PostsImport
189+
parentRoute: typeof PostsRouteImport
190190
}
191191
'/users/': {
192192
id: '/users/'
193193
path: '/'
194194
fullPath: '/users/'
195195
preLoaderRoute: typeof UsersIndexImport
196-
parentRoute: typeof UsersImport
196+
parentRoute: typeof UsersRouteImport
197197
}
198198
'/_pathlessLayout/_nested-layout/route-a': {
199199
id: '/_pathlessLayout/_nested-layout/route-a'
@@ -221,6 +221,34 @@ declare module '@tanstack/react-router' {
221221

222222
// Create and export the route tree
223223

224+
interface PostsRouteRouteChildren {
225+
PostsPostIdRoute: typeof PostsPostIdRoute
226+
PostsIndexRoute: typeof PostsIndexRoute
227+
}
228+
229+
const PostsRouteRouteChildren: PostsRouteRouteChildren = {
230+
PostsPostIdRoute: PostsPostIdRoute,
231+
PostsIndexRoute: PostsIndexRoute,
232+
}
233+
234+
const PostsRouteRouteWithChildren = PostsRouteRoute._addFileChildren(
235+
PostsRouteRouteChildren,
236+
)
237+
238+
interface UsersRouteRouteChildren {
239+
UsersUserIdRoute: typeof UsersUserIdRoute
240+
UsersIndexRoute: typeof UsersIndexRoute
241+
}
242+
243+
const UsersRouteRouteChildren: UsersRouteRouteChildren = {
244+
UsersUserIdRoute: UsersUserIdRoute,
245+
UsersIndexRoute: UsersIndexRoute,
246+
}
247+
248+
const UsersRouteRouteWithChildren = UsersRouteRoute._addFileChildren(
249+
UsersRouteRouteChildren,
250+
)
251+
224252
interface PathlessLayoutNestedLayoutRouteChildren {
225253
PathlessLayoutNestedLayoutRouteARoute: typeof PathlessLayoutNestedLayoutRouteARoute
226254
PathlessLayoutNestedLayoutRouteBRoute: typeof PathlessLayoutNestedLayoutRouteBRoute
@@ -251,37 +279,13 @@ const PathlessLayoutRouteWithChildren = PathlessLayoutRoute._addFileChildren(
251279
PathlessLayoutRouteChildren,
252280
)
253281

254-
interface PostsRouteChildren {
255-
PostsPostIdRoute: typeof PostsPostIdRoute
256-
PostsIndexRoute: typeof PostsIndexRoute
257-
}
258-
259-
const PostsRouteChildren: PostsRouteChildren = {
260-
PostsPostIdRoute: PostsPostIdRoute,
261-
PostsIndexRoute: PostsIndexRoute,
262-
}
263-
264-
const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren)
265-
266-
interface UsersRouteChildren {
267-
UsersUserIdRoute: typeof UsersUserIdRoute
268-
UsersIndexRoute: typeof UsersIndexRoute
269-
}
270-
271-
const UsersRouteChildren: UsersRouteChildren = {
272-
UsersUserIdRoute: UsersUserIdRoute,
273-
UsersIndexRoute: UsersIndexRoute,
274-
}
275-
276-
const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren)
277-
278282
export interface FileRoutesByFullPath {
279283
'/': typeof IndexRoute
284+
'/posts': typeof PostsRouteRouteWithChildren
285+
'/users': typeof UsersRouteRouteWithChildren
280286
'': typeof PathlessLayoutNestedLayoutRouteWithChildren
281287
'/deferred': typeof DeferredRoute
282-
'/posts': typeof PostsRouteWithChildren
283288
'/redirect': typeof RedirectRoute
284-
'/users': typeof UsersRouteWithChildren
285289
'/posts/$postId': typeof PostsPostIdRoute
286290
'/users/$userId': typeof UsersUserIdRoute
287291
'/posts/': typeof PostsIndexRoute
@@ -308,11 +312,11 @@ export interface FileRoutesByTo {
308312
export interface FileRoutesById {
309313
__root__: typeof rootRoute
310314
'/': typeof IndexRoute
315+
'/posts': typeof PostsRouteRouteWithChildren
316+
'/users': typeof UsersRouteRouteWithChildren
311317
'/_pathlessLayout': typeof PathlessLayoutRouteWithChildren
312318
'/deferred': typeof DeferredRoute
313-
'/posts': typeof PostsRouteWithChildren
314319
'/redirect': typeof RedirectRoute
315-
'/users': typeof UsersRouteWithChildren
316320
'/_pathlessLayout/_nested-layout': typeof PathlessLayoutNestedLayoutRouteWithChildren
317321
'/posts/$postId': typeof PostsPostIdRoute
318322
'/users/$userId': typeof UsersUserIdRoute
@@ -327,11 +331,11 @@ export interface FileRouteTypes {
327331
fileRoutesByFullPath: FileRoutesByFullPath
328332
fullPaths:
329333
| '/'
334+
| '/posts'
335+
| '/users'
330336
| ''
331337
| '/deferred'
332-
| '/posts'
333338
| '/redirect'
334-
| '/users'
335339
| '/posts/$postId'
336340
| '/users/$userId'
337341
| '/posts/'
@@ -355,11 +359,11 @@ export interface FileRouteTypes {
355359
id:
356360
| '__root__'
357361
| '/'
362+
| '/posts'
363+
| '/users'
358364
| '/_pathlessLayout'
359365
| '/deferred'
360-
| '/posts'
361366
| '/redirect'
362-
| '/users'
363367
| '/_pathlessLayout/_nested-layout'
364368
| '/posts/$postId'
365369
| '/users/$userId'
@@ -373,21 +377,21 @@ export interface FileRouteTypes {
373377

374378
export interface RootRouteChildren {
375379
IndexRoute: typeof IndexRoute
380+
PostsRouteRoute: typeof PostsRouteRouteWithChildren
381+
UsersRouteRoute: typeof UsersRouteRouteWithChildren
376382
PathlessLayoutRoute: typeof PathlessLayoutRouteWithChildren
377383
DeferredRoute: typeof DeferredRoute
378-
PostsRoute: typeof PostsRouteWithChildren
379384
RedirectRoute: typeof RedirectRoute
380-
UsersRoute: typeof UsersRouteWithChildren
381385
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
382386
}
383387

384388
const rootRouteChildren: RootRouteChildren = {
385389
IndexRoute: IndexRoute,
390+
PostsRouteRoute: PostsRouteRouteWithChildren,
391+
UsersRouteRoute: UsersRouteRouteWithChildren,
386392
PathlessLayoutRoute: PathlessLayoutRouteWithChildren,
387393
DeferredRoute: DeferredRoute,
388-
PostsRoute: PostsRouteWithChildren,
389394
RedirectRoute: RedirectRoute,
390-
UsersRoute: UsersRouteWithChildren,
391395
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
392396
}
393397

@@ -402,43 +406,43 @@ export const routeTree = rootRoute
402406
"filePath": "__root.tsx",
403407
"children": [
404408
"/",
409+
"/posts",
410+
"/users",
405411
"/_pathlessLayout",
406412
"/deferred",
407-
"/posts",
408413
"/redirect",
409-
"/users",
410414
"/posts_/$postId/deep"
411415
]
412416
},
413417
"/": {
414418
"filePath": "index.tsx"
415419
},
416-
"/_pathlessLayout": {
417-
"filePath": "_pathlessLayout.tsx",
418-
"children": [
419-
"/_pathlessLayout/_nested-layout"
420-
]
421-
},
422-
"/deferred": {
423-
"filePath": "deferred.tsx"
424-
},
425420
"/posts": {
426-
"filePath": "posts.tsx",
421+
"filePath": "posts.route.tsx",
427422
"children": [
428423
"/posts/$postId",
429424
"/posts/"
430425
]
431426
},
432-
"/redirect": {
433-
"filePath": "redirect.tsx"
434-
},
435427
"/users": {
436-
"filePath": "users.tsx",
428+
"filePath": "users.route.tsx",
437429
"children": [
438430
"/users/$userId",
439431
"/users/"
440432
]
441433
},
434+
"/_pathlessLayout": {
435+
"filePath": "_pathlessLayout.tsx",
436+
"children": [
437+
"/_pathlessLayout/_nested-layout"
438+
]
439+
},
440+
"/deferred": {
441+
"filePath": "deferred.tsx"
442+
},
443+
"/redirect": {
444+
"filePath": "redirect.tsx"
445+
},
442446
"/_pathlessLayout/_nested-layout": {
443447
"filePath": "_pathlessLayout/_nested-layout.tsx",
444448
"parent": "/_pathlessLayout",
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# The following environment variables are required to run the application
2+
WORKOS_REDIRECT_URI=http://localhost:3000/api/auth/callback
3+
WORKOS_API_KEY='<YOUR_API_KEY>'
4+
WORKOS_CLIENT_ID='<YOUR_CLIENT_ID>'
5+
WORKOS_COOKIE_PASSWORD='<YOUR_COOKIE_PASSWORD>'

0 commit comments

Comments
 (0)