Skip to content

Conversation

@shrutikapoor08
Copy link
Contributor

Add DevJokes Tutorial: Reading and Writing Files

image

Description

Adds a tutorial showing how to build a full-stack DevJokes app with TanStack Start. Users learn to create server functions for reading and writing to files, build React components, and implement data fetching with TanStack Router.

Key Features

  • Server functions with createServerFn
  • File-based data storage with Node.js fs
  • Form handling and data validation
  • Data refreshing with router.invalidate()
  • Complete UI with Tailwind CSS

Demo

https://youtu.be/zd0rtKbtlgU

Reference

Complete code available at: https://github.com/shrutikapoor08/devjokes

@github-actions github-actions bot added the documentation Everything documentation related label May 5, 2025
@nx-cloud
Copy link

nx-cloud bot commented May 5, 2025

View your CI Pipeline Execution ↗ for commit b0e48e3.

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded <1s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-05 09:40:21 UTC

@tannerlinsley tannerlinsley merged commit ba8a1c8 into main May 5, 2025
1 check passed
@tannerlinsley tannerlinsley deleted the skapoor-devjokes-tutorial branch May 5, 2025 14:23

At this point, your app will look like this -

![TanStack Start Welcome Page After Setup](https://res.cloudinary.com/dubc3wnbv/image/upload/v1746312482/Photo-1_lpechn.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we inline the images in the repo?

See, docs/router/framework/react/guide/custom-search-param-serialization.md.

This should have it work where the website will automatically choose the image based on the selected branch.


```tsx
// src/serverActions/jokesActions.ts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space/line break.


With a little Tailwind styling, the app should look like this:

![DevJoke App with 5 DevJokes](https://res.cloudinary.com/dubc3wnbv/image/upload/v1746313558/Screenshot_2025-05-03_at_4.04.50_PM_w0eern.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image in-lining.

```

With this, our UI should look like this:
![DevJoke App with Form to Add Jokes](https://res.cloudinary.com/dubc3wnbv/image/upload/v1746356983/Screenshot_2025-05-04_at_4.06.57_AM_dkgvsm.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image in-lining.


### Data Flow

![Data Flow Diagram](https://res.cloudinary.com/dubc3wnbv/image/upload/v1746437057/Screenshot_2025-05-05_at_2.23.11_AM_wxfz2m.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image in-lining.


## Nice to know

- [Server Side Rendering (SSR)](https://tanstack.com/router/latest/docs/framework/react/guide/ssr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use absolute linking, without the origin.

Suggested change
- [Server Side Rendering (SSR)](https://tanstack.com/router/latest/docs/framework/react/guide/ssr)
- [Server Side Rendering (SSR)](/router/latest/docs/framework/react/guide/ssr)

tannerlinsley pushed a commit that referenced this pull request Sep 17, 2025
Incorporating feedback from PR -
#4089. Changes made -
1. Moved images to `assets` folder on suggestion
2. Changed URLs from absolute to relative. 
3. Adding an in-line sequence diagram

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Newly added jokes now receive unique identifiers, improving
reliability when creating new entries.

* **Documentation**
* Updated links to internal paths for SSR, router concepts, and React
Query sections.
* Switched images to repository-hosted assets for consistency and
availability.
* Replaced the data flow image with an inline Mermaid sequence diagram
covering home-page loading and add-joke flows, including data refresh
behavior.
  * Minor formatting cleanup.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Everything documentation related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants