Skip to content

Commit 4252b83

Browse files
committed
reset react basic auth
1 parent 6f32364 commit 4252b83

File tree

18 files changed

+136
-197
lines changed

18 files changed

+136
-197
lines changed

examples/react/start-basic-auth/.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ yarn.lock
77
.cache
88
.vercel
99
.output
10-
1110
/build/
1211
/api/
1312
/server/build
14-
/public/build
15-
# Sentry Config File
13+
/public/build# Sentry Config File
1614
.env.sentry-build-plugin
1715
/test-results/
1816
/playwright-report/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"files.watcherExclude": {
3+
"**/routeTree.gen.ts": true
4+
},
5+
"search.exclude": {
6+
"**/routeTree.gen.ts": true
7+
},
8+
"files.readonlyInclude": {
9+
"**/routeTree.gen.ts": true
10+
}
11+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Welcome to TanStack.com!
2+
3+
This site is built with TanStack Router!
4+
5+
- [TanStack Router Docs](https://tanstack.com/router)
6+
7+
It's deployed automagically with Netlify!
8+
9+
- [Netlify](https://netlify.com/)
10+
11+
## Development
12+
13+
From your terminal:
14+
15+
```sh
16+
pnpm install
17+
pnpm dev
18+
```
19+
20+
This starts your app in development mode, rebuilding assets on file changes.
21+
22+
## Editing and previewing the docs of TanStack projects locally
23+
24+
The documentations for all TanStack projects except for `React Charts` are hosted on [https://tanstack.com](https://tanstack.com), powered by this TanStack Router app.
25+
In production, the markdown doc pages are fetched from the GitHub repos of the projects, but in development they are read from the local file system.
26+
27+
Follow these steps if you want to edit the doc pages of a project (in these steps we'll assume it's [`TanStack/form`](https://github.com/tanstack/form)) and preview them locally :
28+
29+
1. Create a new directory called `tanstack`.
30+
31+
```sh
32+
mkdir tanstack
33+
```
34+
35+
2. Enter the directory and clone this repo and the repo of the project there.
36+
37+
```sh
38+
cd tanstack
39+
git clone git@github.com:TanStack/tanstack.com.git
40+
git clone git@github.com:TanStack/form.git
41+
```
42+
43+
> [!NOTE]
44+
> Your `tanstack` directory should look like this:
45+
>
46+
> ```
47+
> tanstack/
48+
> |
49+
> +-- form/
50+
> |
51+
> +-- tanstack.com/
52+
> ```
53+
54+
> [!WARNING]
55+
> Make sure the name of the directory in your local file system matches the name of the project's repo. For example, `tanstack/form` must be cloned into `form` (this is the default) instead of `some-other-name`, because that way, the doc pages won't be found.
56+
57+
3. Enter the `tanstack/tanstack.com` directory, install the dependencies and run the app in dev mode:
58+
59+
```sh
60+
cd tanstack.com
61+
pnpm i
62+
# The app will run on https://localhost:3000 by default
63+
pnpm dev
64+
```
65+
66+
4. Now you can visit http://localhost:3000/form/latest/docs/overview in the browser and see the changes you make in `tanstack/form/docs`.
67+
68+
> [!NOTE]
69+
> The updated pages need to be manually reloaded in the browser.
70+
71+
> [!WARNING]
72+
> You will need to update the `docs/config.json` file (in the project's repo) if you add a new doc page!
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
{
2-
"name": "tanstack-react-start-e2e-basic-auth",
2+
"name": "tanstack-start-example-basic-auth",
33
"private": true,
44
"sideEffects": false,
55
"type": "module",
66
"scripts": {
7-
"dev": "vite dev --port 3000",
8-
"dev:e2e": "vite dev",
7+
"dev": "vite dev",
98
"build": "vite build",
10-
"start": "node .output/server/index.mjs",
11-
"prisma-generate": "prisma generate",
12-
"test:e2e": "exit 0; rm -rf port*.txt; pnpm run prisma-generate && playwright test --project=chromium"
9+
"start": "vite start",
10+
"prisma-generate": "prisma generate"
1311
},
1412
"dependencies": {
1513
"@prisma/client": "5.22.0",
16-
"@tanstack/react-router": "workspace:^",
17-
"@tanstack/react-router-devtools": "workspace:^",
18-
"@tanstack/react-start": "workspace:^",
14+
"@tanstack/react-router": "^1.133.20",
15+
"@tanstack/react-router-devtools": "^1.133.20",
16+
"@tanstack/react-start": "^1.133.20",
1917
"prisma": "^5.22.0",
2018
"react": "^19.0.0",
2119
"react-dom": "^19.0.0",
2220
"redaxios": "^0.5.1",
23-
"tailwind-merge": "^2.6.0",
24-
"vite": "^7.1.7"
21+
"tailwind-merge": "^2.6.0"
2522
},
2623
"devDependencies": {
27-
"@playwright/test": "^1.50.1",
28-
"@tanstack/router-e2e-utils": "workspace:^",
29-
"@types/node": "^22.10.2",
24+
"@vitejs/plugin-react": "^4.3.4",
25+
"@types/node": "^22.5.4",
3026
"@types/react": "^19.0.8",
3127
"@types/react-dom": "^19.0.3",
32-
"@vitejs/plugin-react": "^4.3.4",
33-
"autoprefixer": "^10.4.20",
3428
"postcss": "^8.5.1",
29+
"autoprefixer": "^10.4.20",
3530
"tailwindcss": "^3.4.17",
3631
"typescript": "^5.7.2",
32+
"vite": "^7.1.7",
3733
"vite-tsconfig-paths": "^5.1.4"
3834
}
3935
}

examples/react/start-basic-auth/playwright.config.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Route as LogoutRouteImport } from './routes/logout'
1414
import { Route as LoginRouteImport } from './routes/login'
1515
import { Route as AuthedRouteImport } from './routes/_authed'
1616
import { Route as IndexRouteImport } from './routes/index'
17-
import { Route as AuthedPostsRouteImport } from './routes/_authed/posts'
17+
import { Route as AuthedPostsRouteRouteImport } from './routes/_authed/posts.route'
1818
import { Route as AuthedPostsIndexRouteImport } from './routes/_authed/posts.index'
1919
import { Route as AuthedPostsPostIdRouteImport } from './routes/_authed/posts.$postId'
2020

@@ -42,28 +42,28 @@ const IndexRoute = IndexRouteImport.update({
4242
path: '/',
4343
getParentRoute: () => rootRouteImport,
4444
} as any)
45-
const AuthedPostsRoute = AuthedPostsRouteImport.update({
45+
const AuthedPostsRouteRoute = AuthedPostsRouteRouteImport.update({
4646
id: '/posts',
4747
path: '/posts',
4848
getParentRoute: () => AuthedRoute,
4949
} as any)
5050
const AuthedPostsIndexRoute = AuthedPostsIndexRouteImport.update({
5151
id: '/',
5252
path: '/',
53-
getParentRoute: () => AuthedPostsRoute,
53+
getParentRoute: () => AuthedPostsRouteRoute,
5454
} as any)
5555
const AuthedPostsPostIdRoute = AuthedPostsPostIdRouteImport.update({
5656
id: '/$postId',
5757
path: '/$postId',
58-
getParentRoute: () => AuthedPostsRoute,
58+
getParentRoute: () => AuthedPostsRouteRoute,
5959
} as any)
6060

6161
export interface FileRoutesByFullPath {
6262
'/': typeof IndexRoute
6363
'/login': typeof LoginRoute
6464
'/logout': typeof LogoutRoute
6565
'/signup': typeof SignupRoute
66-
'/posts': typeof AuthedPostsRouteWithChildren
66+
'/posts': typeof AuthedPostsRouteRouteWithChildren
6767
'/posts/$postId': typeof AuthedPostsPostIdRoute
6868
'/posts/': typeof AuthedPostsIndexRoute
6969
}
@@ -82,7 +82,7 @@ export interface FileRoutesById {
8282
'/login': typeof LoginRoute
8383
'/logout': typeof LogoutRoute
8484
'/signup': typeof SignupRoute
85-
'/_authed/posts': typeof AuthedPostsRouteWithChildren
85+
'/_authed/posts': typeof AuthedPostsRouteRouteWithChildren
8686
'/_authed/posts/$postId': typeof AuthedPostsPostIdRoute
8787
'/_authed/posts/': typeof AuthedPostsIndexRoute
8888
}
@@ -159,46 +159,45 @@ declare module '@tanstack/react-router' {
159159
id: '/_authed/posts'
160160
path: '/posts'
161161
fullPath: '/posts'
162-
preLoaderRoute: typeof AuthedPostsRouteImport
162+
preLoaderRoute: typeof AuthedPostsRouteRouteImport
163163
parentRoute: typeof AuthedRoute
164164
}
165165
'/_authed/posts/': {
166166
id: '/_authed/posts/'
167167
path: '/'
168168
fullPath: '/posts/'
169169
preLoaderRoute: typeof AuthedPostsIndexRouteImport
170-
parentRoute: typeof AuthedPostsRoute
170+
parentRoute: typeof AuthedPostsRouteRoute
171171
}
172172
'/_authed/posts/$postId': {
173173
id: '/_authed/posts/$postId'
174174
path: '/$postId'
175175
fullPath: '/posts/$postId'
176176
preLoaderRoute: typeof AuthedPostsPostIdRouteImport
177-
parentRoute: typeof AuthedPostsRoute
177+
parentRoute: typeof AuthedPostsRouteRoute
178178
}
179179
}
180180
}
181181

182-
interface AuthedPostsRouteChildren {
182+
interface AuthedPostsRouteRouteChildren {
183183
AuthedPostsPostIdRoute: typeof AuthedPostsPostIdRoute
184184
AuthedPostsIndexRoute: typeof AuthedPostsIndexRoute
185185
}
186186

187-
const AuthedPostsRouteChildren: AuthedPostsRouteChildren = {
187+
const AuthedPostsRouteRouteChildren: AuthedPostsRouteRouteChildren = {
188188
AuthedPostsPostIdRoute: AuthedPostsPostIdRoute,
189189
AuthedPostsIndexRoute: AuthedPostsIndexRoute,
190190
}
191191

192-
const AuthedPostsRouteWithChildren = AuthedPostsRoute._addFileChildren(
193-
AuthedPostsRouteChildren,
194-
)
192+
const AuthedPostsRouteRouteWithChildren =
193+
AuthedPostsRouteRoute._addFileChildren(AuthedPostsRouteRouteChildren)
195194

196195
interface AuthedRouteChildren {
197-
AuthedPostsRoute: typeof AuthedPostsRouteWithChildren
196+
AuthedPostsRouteRoute: typeof AuthedPostsRouteRouteWithChildren
198197
}
199198

200199
const AuthedRouteChildren: AuthedRouteChildren = {
201-
AuthedPostsRoute: AuthedPostsRouteWithChildren,
200+
AuthedPostsRouteRoute: AuthedPostsRouteRouteWithChildren,
202201
}
203202

204203
const AuthedRouteWithChildren =

examples/react/start-basic-auth/src/router.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ import { NotFound } from './components/NotFound'
66
export function getRouter() {
77
const router = createRouter({
88
routeTree,
9-
scrollRestoration: true,
109
defaultPreload: 'intent',
1110
defaultErrorComponent: DefaultCatchBoundary,
1211
defaultNotFoundComponent: () => <NotFound />,
12+
scrollRestoration: true,
1313
})
1414

1515
return router
1616
}
17+
18+
declare module '@tanstack/react-router' {
19+
interface Register {
20+
router: ReturnType<typeof getRouter>
21+
}
22+
}

examples/react/start-basic-auth/src/routes/__root.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
1010
import { createServerFn } from '@tanstack/react-start'
1111
import * as React from 'react'
12-
1312
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary.js'
1413
import { NotFound } from '~/components/NotFound.js'
1514
import appCss from '~/styles/app.css?url'

examples/react/start-basic-auth/src/routes/_authed.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { createFileRoute } from '@tanstack/react-router'
22
import { createServerFn } from '@tanstack/react-start'
3-
43
import { hashPassword, prismaClient } from '~/utils/prisma'
54
import { Login } from '~/components/Login'
65
import { useAppSession } from '~/utils/session'
76

8-
export const loginFn = createServerFn({
9-
method: 'POST',
10-
})
11-
.inputValidator((payload: { email: string; password: string }) => payload)
7+
export const loginFn = createServerFn({ method: 'POST' })
8+
.inputValidator((d: { email: string; password: string }) => d)
129
.handler(async ({ data }) => {
1310
// Find the user
1411
const user = await prismaClient.user.findUnique({

examples/react/start-basic-auth/src/routes/_authed/posts.$postId.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ErrorComponent, createFileRoute } from '@tanstack/react-router'
22
import type { ErrorComponentProps } from '@tanstack/react-router'
3-
43
import { NotFound } from '~/components/NotFound.js'
54
import { fetchPost } from '~/utils/posts.js'
65

0 commit comments

Comments
 (0)