Skip to content

Commit 4d48138

Browse files
author
Brenley Dueck
authored
chore: add tanstack router example with ssr false (#1821)
1 parent 0c9bc47 commit 4d48138

17 files changed

Lines changed: 811 additions & 2 deletions

File tree

examples/pnpm-lock.yaml

Lines changed: 470 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SolidStart
2+
3+
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);
4+
5+
## Creating a project
6+
7+
```bash
8+
# create a new project in the current directory
9+
npm init solid@latest
10+
11+
# create a new project in my-app
12+
npm init solid@latest my-app
13+
```
14+
15+
## Developing
16+
17+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
18+
19+
```bash
20+
npm run dev
21+
22+
# or start the server and open the app in a new browser tab
23+
npm run dev -- --open
24+
```
25+
26+
## Building
27+
28+
Solid apps are built with _presets_, which optimise your project for deployment to different environments.
29+
30+
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different preset, add it to the `devDependencies` in `package.json` and specify in your `app.config.js`.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from "@solidjs/start/config";
2+
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
3+
4+
export default defineConfig({
5+
ssr: false,
6+
vite: {
7+
plugins: [TanStackRouterVite({ target: "solid" })]
8+
}
9+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "with-tanstack-router",
3+
"type": "module",
4+
"scripts": {
5+
"dev": "vinxi dev",
6+
"build": "vinxi build",
7+
"start": "vinxi start",
8+
"version": "vinxi version"
9+
},
10+
"dependencies": {
11+
"@tanstack/solid-router": "^1.108.0",
12+
"@tanstack/router-plugin": "^1.108.0",
13+
"@solidjs/start": "^1.1.0",
14+
"solid-js": "^1.9.2",
15+
"vinxi": "^0.5.3"
16+
},
17+
"engines": {
18+
"node": ">=22"
19+
}
20+
}
664 Bytes
Binary file not shown.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
body {
2+
font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
3+
}
4+
5+
a {
6+
margin-right: 1rem;
7+
}
8+
9+
main {
10+
text-align: center;
11+
padding: 1em;
12+
margin: 0 auto;
13+
}
14+
15+
h1 {
16+
color: #335d92;
17+
text-transform: uppercase;
18+
font-size: 4rem;
19+
font-weight: 100;
20+
line-height: 1.1;
21+
margin: 4rem auto;
22+
max-width: 14rem;
23+
}
24+
25+
p {
26+
max-width: 14rem;
27+
margin: 2rem auto;
28+
line-height: 1.35;
29+
}
30+
31+
@media (min-width: 480px) {
32+
h1 {
33+
max-width: none;
34+
}
35+
36+
p {
37+
max-width: none;
38+
}
39+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { RouterProvider, createRouter } from "@tanstack/solid-router";
2+
import { routeTree } from "./routeTree.gen";
3+
4+
import "./app.css";
5+
6+
const router = createRouter({
7+
routeTree,
8+
defaultPreload: "intent",
9+
defaultStaleTime: 5000,
10+
scrollRestoration: true
11+
});
12+
13+
// Register things for typesafety
14+
declare module "@tanstack/solid-router" {
15+
interface Register {
16+
router: typeof router;
17+
}
18+
}
19+
20+
export default function App() {
21+
return <RouterProvider router={router} />;
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.increment {
2+
font-family: inherit;
3+
font-size: inherit;
4+
padding: 1em 2em;
5+
color: #335d92;
6+
background-color: rgba(68, 107, 158, 0.1);
7+
border-radius: 2em;
8+
border: 2px solid rgba(68, 107, 158, 0);
9+
outline: none;
10+
width: 200px;
11+
font-variant-numeric: tabular-nums;
12+
cursor: pointer;
13+
}
14+
15+
.increment:focus {
16+
border: 2px solid #335d92;
17+
}
18+
19+
.increment:active {
20+
background-color: rgba(68, 107, 158, 0.2);
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createSignal } from "solid-js";
2+
import "./Counter.css";
3+
4+
export default function Counter() {
5+
const [count, setCount] = createSignal(0);
6+
return (
7+
<button class="increment" onClick={() => setCount(count() + 1)} type="button">
8+
Clicks: {count()}
9+
</button>
10+
);
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @refresh reload
2+
import { mount, StartClient } from "@solidjs/start/client";
3+
4+
mount(() => <StartClient />, document.getElementById("app")!);

0 commit comments

Comments
 (0)