Skip to content

Commit 8aaeb36

Browse files
committed
wip
1 parent 38f4fd9 commit 8aaeb36

File tree

1 file changed

+111
-10
lines changed

1 file changed

+111
-10
lines changed

website/docs/quickstart.md

Lines changed: 111 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,128 @@ Open in your web browser at [localhost:5173](http://localhost:5173).
4646

4747
Lets change some data in Postgres and see the app instantly react.
4848

49-
Connect to Postgres using `psql`:
49+
Arrange your windows so you can see the app running in your web browser and your terminal at the same time. Open the "Default" project page in the browser.
50+
51+
Then in your terminal, connect to Postgres using `psql`:
5052

5153
```shell
52-
pnpm dev
54+
pnpm psql
55+
```
56+
57+
This will open the psql shell:
58+
59+
```
60+
psql (17.4, server 17.6)
61+
Type "help" for help.
62+
63+
electric=#
5364
```
5465

55-
- [ ] connect to the DB using the DATABASE_URL in `.env`
56-
- [ ] manually edit the data and see the app update
66+
Update the project name:
67+
68+
```sql
69+
UPDATE projects SET name = 'Baz bam!';
70+
```
71+
72+
Keep changing the project name. The app updates instantly in real-time — for all users.
5773

5874
### Develop the app
5975

60-
- [ ] change the code and see what happens
61-
- [ ] load the AGENTS.md into your LLM and have it make changes
62-
- [ ] see the blog post on developing with Electric and TanStack DB and the Interactive Guide to TanStack DB for a high level intro on the stack
63-
- [ ] dive into the Tutorial for more in depth
76+
The starter app is a fully-fledged [TanStack Start](https://tanstack.com/start) application with routing and auth, ready for you to build out into a real app.
77+
78+
#### Changing the code
79+
80+
Let's change the code and see what happens. Open a project page in your browser and add a few todos. Note that new todo items are sorted last, at the bottom of the list.
81+
82+
Open up the code for the project page in `src/routes/_authenticated/project/$projectId.tsx`. You can see the live query for the todo list towards the top of the `ProjectPage` component:
83+
84+
```tsx
85+
const { data: todos } = useLiveQuery(
86+
(q) =>
87+
q
88+
.from({ todoCollection })
89+
.where(({ todoCollection }) =>
90+
eq(todoCollection.project_id, projectId, 10)
91+
)
92+
.orderBy(({ todoCollection }) => todoCollection.created_at),
93+
[projectId]
94+
)
95+
```
96+
97+
This queries the local TanStack DB `todoCollection` for todos that belong to the current project and sorts them by `created_at`. The default sort order is `asc`. Let's update the code to make that explicit.
98+
99+
```tsx
100+
const direction = 'asc'
101+
102+
const { data: todos } = useLiveQuery(
103+
(q) =>
104+
q
105+
.from({ todoCollection })
106+
.where(({ todoCollection }) =>
107+
eq(todoCollection.project_id, parseInt(projectId, 10))
108+
)
109+
.orderBy(({ todoCollection }) => todoCollection.created_at, direction),
110+
[projectId, direction]
111+
)
112+
```
113+
114+
Now, with the browser page open and visible, toggle the direction value between `asc` and `desc`:
115+
116+
```tsx
117+
const direction = 'desc'
118+
```
119+
120+
You'll see the todo list re-ordering live in the page.
121+
122+
See the blog post introducing [developing with Electric and TanStack DB](/blog/2025/07/29/local-first-sync-with-tanstack-db) and the [Interactive Guide to TanStack DB](https://frontendatscale.com/blog/tanstack-db/) for a high level intro on the stack.
123+
124+
Dive into the [Tutorial](tutorial.md) for a more in-depth walkthrough of how to develop out a production-quality app with Electric and TanStack DB.
125+
126+
#### Using coding agents
127+
128+
The quickstart template ships with an `AGENTS.md` file. Load this into your LLM and have it make changes for you.
129+
130+
For example:
131+
132+
```
133+
Read AGENTS.md. Sort the todo list on the project page alphabetically.
134+
```
64135

65136
### Claim the resources
66137

67-
- [ ] claim the resources
138+
The Postgres database and Electric sync service provisioned when you generated the app are temporary. They'll be scaled down automatically and then deleted in a few days time.
139+
140+
To continue using them, you can claim them. This allows you to create or sign-in to accounts with Electric Cloud (for the sync service) and Neon (for the database hosting) and move the resources into your accounts so you can manage and control them.
141+
142+
To claim the resources run:
143+
144+
```shell
145+
pnpm claim
146+
```
147+
148+
Follow the instructions in the your web browser.
149+
150+
### Deploy and share the app
151+
152+
To deploy your local app to [Netlify](https://tanstack.com/start/latest/docs/framework/react/hosting#what-is-netlify), run:
153+
154+
```sh
155+
pnpm deploy
156+
```
157+
158+
TanStack Start is designed to work with any hosting provider. See the [Hosting docs](https://tanstack.com/start/latest/docs/framework/react/hosting) for instructions.
159+
160+
161+
162+
163+
164+
165+
166+
so if you already have a hosting provider in mind, you can deploy your application there using the full-stack APIs provided by TanStack Start.
167+
168+
68169

69-
### Deploy and share
170+
TanStack Start is a full-stack framework powered by TanStack Router. It provides a full-document SSR, streaming, server functions, bundling, and more. Thanks to Vite, it's ready to develop and deploy to any hosting provider or runtime you want!
70171

71172
- [ ] deploy the app
72173

0 commit comments

Comments
 (0)