Skip to content

Commit 2262f8b

Browse files
committed
react example
1 parent 4252b83 commit 2262f8b

28 files changed

+262
-325
lines changed

examples/solid/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: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
{
2-
"name": "tanstack-solid-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/solid-router": "workspace:^",
17-
"@tanstack/solid-router-devtools": "workspace:^",
18-
"@tanstack/solid-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",
20-
"solid-js": "^1.9.5",
18+
"react": "^19.0.0",
19+
"react-dom": "^19.0.0",
2120
"redaxios": "^0.5.1",
22-
"tailwind-merge": "^2.6.0",
23-
"vite": "^7.1.7"
21+
"tailwind-merge": "^2.6.0"
2422
},
2523
"devDependencies": {
26-
"@playwright/test": "^1.50.1",
27-
"@tanstack/router-e2e-utils": "workspace:^",
28-
"@types/node": "^22.10.2",
29-
"vite-plugin-solid": "^2.11.9",
30-
"autoprefixer": "^10.4.20",
24+
"@vitejs/plugin-react": "^4.3.4",
25+
"@types/node": "^22.5.4",
26+
"@types/react": "^19.0.8",
27+
"@types/react-dom": "^19.0.3",
3128
"postcss": "^8.5.1",
29+
"autoprefixer": "^10.4.20",
3230
"tailwindcss": "^3.4.17",
3331
"typescript": "^5.7.2",
32+
"vite": "^7.1.7",
3433
"vite-tsconfig-paths": "^5.1.4"
3534
}
3635
}

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

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

examples/solid/start-basic-auth/src/components/Auth.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
1-
import type { JSX } from 'solid-js'
2-
31
export function Auth({
42
actionText,
53
onSubmit,
64
status,
75
afterSubmit,
86
}: {
97
actionText: string
10-
onSubmit: (e: HTMLFormElement) => void
8+
onSubmit: (e: React.FormEvent<HTMLFormElement>) => void
119
status: 'pending' | 'idle' | 'success' | 'error'
12-
afterSubmit?: JSX.Element
10+
afterSubmit?: React.ReactNode
1311
}) {
1412
return (
15-
<div class="fixed inset-0 bg-white dark:bg-black flex items-start justify-center p-8">
16-
<div class="bg-white dark:bg-gray-900 p-8 rounded-lg shadow-lg">
17-
<h1 class="text-2xl font-bold mb-4">{actionText}</h1>
13+
<div className="fixed inset-0 bg-white dark:bg-black flex items-start justify-center p-8">
14+
<div className="bg-white dark:bg-gray-900 p-8 rounded-lg shadow-lg">
15+
<h1 className="text-2xl font-bold mb-4">{actionText}</h1>
1816
<form
19-
onSubmit={(e: any) => {
17+
onSubmit={(e) => {
2018
e.preventDefault()
2119
onSubmit(e)
2220
}}
23-
class="space-y-4"
21+
className="space-y-4"
2422
>
2523
<div>
26-
<label for="email" class="block text-xs">
24+
<label htmlFor="email" className="block text-xs">
2725
Email
2826
</label>
2927
<input
3028
type="email"
3129
name="email"
3230
id="email"
33-
class="px-2 py-1 w-full rounded border border-gray-500/20 bg-white dark:bg-gray-800"
31+
className="px-2 py-1 w-full rounded border border-gray-500/20 bg-white dark:bg-gray-800"
3432
/>
3533
</div>
3634
<div>
37-
<label for="password" class="block text-xs">
35+
<label htmlFor="password" className="block text-xs">
3836
Password
3937
</label>
4038
<input
4139
type="password"
4240
name="password"
4341
id="password"
44-
class="px-2 py-1 w-full rounded border border-gray-500/20 bg-white dark:bg-gray-800"
42+
className="px-2 py-1 w-full rounded border border-gray-500/20 bg-white dark:bg-gray-800"
4543
/>
4644
</div>
4745
<button
4846
type="submit"
49-
class="w-full bg-cyan-600 text-white rounded py-2 font-black uppercase"
47+
className="w-full bg-cyan-600 text-white rounded py-2 font-black uppercase"
5048
disabled={status === 'pending'}
5149
>
5250
{status === 'pending' ? '...' : actionText}

examples/solid/start-basic-auth/src/components/DefaultCatchBoundary.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {
44
rootRouteId,
55
useMatch,
66
useRouter,
7-
} from '@tanstack/solid-router'
8-
import type { ErrorComponentProps } from '@tanstack/solid-router'
7+
} from '@tanstack/react-router'
8+
import type { ErrorComponentProps } from '@tanstack/react-router'
99

1010
export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
1111
const router = useRouter()
@@ -17,28 +17,28 @@ export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
1717
console.error(error)
1818

1919
return (
20-
<div class="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
20+
<div className="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
2121
<ErrorComponent error={error} />
22-
<div class="flex gap-2 items-center flex-wrap">
22+
<div className="flex gap-2 items-center flex-wrap">
2323
<button
2424
onClick={() => {
2525
router.invalidate()
2626
}}
27-
class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
27+
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
2828
>
2929
Try Again
3030
</button>
31-
{isRoot() ? (
31+
{isRoot ? (
3232
<Link
3333
to="/"
34-
class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
34+
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
3535
>
3636
Home
3737
</Link>
3838
) : (
3939
<Link
4040
to="/"
41-
class={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
41+
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
4242
onClick={(e) => {
4343
e.preventDefault()
4444
window.history.back()

examples/solid/start-basic-auth/src/components/Login.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { useRouter } from '@tanstack/solid-router'
2-
import { useServerFn } from '@tanstack/solid-start'
1+
import { useRouter } from '@tanstack/react-router'
2+
import { useServerFn } from '@tanstack/react-start'
33
import { useMutation } from '../hooks/useMutation'
44
import { loginFn } from '../routes/_authed'
55
import { Auth } from './Auth'
@@ -26,9 +26,9 @@ export function Login() {
2626
return (
2727
<Auth
2828
actionText="Login"
29-
status={loginMutation.status()}
29+
status={loginMutation.status}
3030
onSubmit={(e) => {
31-
const formData = new FormData(e.target as any as HTMLFormElement)
31+
const formData = new FormData(e.target as HTMLFormElement)
3232

3333
loginMutation.mutate({
3434
data: {
@@ -38,13 +38,13 @@ export function Login() {
3838
})
3939
}}
4040
afterSubmit={
41-
loginMutation.data() ? (
41+
loginMutation.data ? (
4242
<>
43-
<div class="text-red-400">{loginMutation.data()?.message}</div>
44-
{loginMutation.data()?.userNotFound ? (
43+
<div className="text-red-400">{loginMutation.data.message}</div>
44+
{loginMutation.data.userNotFound ? (
4545
<div>
4646
<button
47-
class="text-blue-500"
47+
className="text-blue-500"
4848
onClick={(e) => {
4949
const formData = new FormData(
5050
(e.target as HTMLButtonElement).form!,

examples/solid/start-basic-auth/src/components/NotFound.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { Link } from '@tanstack/solid-router'
1+
import { Link } from '@tanstack/react-router'
22

33
export function NotFound({ children }: { children?: any }) {
44
return (
5-
<div class="space-y-2 p-2">
6-
<div class="text-gray-600 dark:text-gray-400">
5+
<div className="space-y-2 p-2">
6+
<div className="text-gray-600 dark:text-gray-400">
77
{children || <p>The page you are looking for does not exist.</p>}
88
</div>
9-
<p class="flex items-center gap-2 flex-wrap">
9+
<p className="flex items-center gap-2 flex-wrap">
1010
<button
1111
onClick={() => window.history.back()}
12-
class="bg-emerald-500 text-white px-2 py-1 rounded uppercase font-black text-sm"
12+
className="bg-emerald-500 text-white px-2 py-1 rounded uppercase font-black text-sm"
1313
>
1414
Go back
1515
</button>
1616
<Link
1717
to="/"
18-
class="bg-cyan-600 text-white px-2 py-1 rounded uppercase font-black text-sm"
18+
className="bg-cyan-600 text-white px-2 py-1 rounded uppercase font-black text-sm"
1919
>
2020
Start Over
2121
</Link>

0 commit comments

Comments
 (0)