Unverified Commit ff43248f authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

docs: add Interactive Apps guide (#94020)

### What?

Adds the Interactive Apps guide
(`docs/01-app/02-guides/interactive-apps.mdx`) with a companion
[Taskboard app](https://github.com/vercel-labs/async-react-demo).

### Why?

There is no end-to-end guide that shows how to coordinate pending work
across Server Functions, transitions, optimistic UI, and caching in a
single app.

### How?

The guide walks through building a task management board in 8 steps,
from a plain Server Component app to one with optimistic UI, streaming,
caching, and prefetching:

1. Stream slow data with Suspense — promise-passing to split reads into
independent boundaries
2. Respond instantly to a toggle — `useOptimistic` + `startTransition`
for a priority cycle
3. Filter with pending feedback — `useTransition` + `data-pending` for
label chips, action props for `ChipGroup`
4. Add comments with instant feedback — `useOptimistic([])` for a
pending-only comment list
5. Move cards between columns — optimistic reducer for drag-and-drop
status updates
6. Manage form lifecycle with useActionState — `isPending`, key-based
reset, double-transition for dialog close
7. Signal pending deletion to a parent — `useOptimistic(false)` +
`data-pending` CSS attribute
8. Make repeat navigation instant — `use cache`, `cacheTag`,
`updateTag`, `unstable_prefetch`

The companion app lives at
[vercel-labs/async-react-demo](https://github.com/vercel-labs/async-react-demo).
The `plain` branch is the starting point, `main` has all 8 steps
applied.

---------
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent 406523ea
...@@ -374,6 +374,8 @@ export function Button() { ...@@ -374,6 +374,8 @@ export function Button() {
} }
``` ```
See the [Building interactive apps](/docs/app/guides/interactive-apps) guide for a deeper walkthrough of responsive interactions, including pending feedback, optimistic UI, transitions, and error handling.
### Refresh data ### Refresh data
After a mutation, you may want to refresh the current page to show the latest data. You can do this by calling [`refresh`](/docs/app/api-reference/functions/refresh) from `next/cache` in a Server Action: After a mutation, you may want to refresh the current page to show the latest data. You can do this by calling [`refresh`](/docs/app/api-reference/functions/refresh) from `next/cache` in a Server Action:
......
This diff is collapsed.
...@@ -227,7 +227,7 @@ function ContactForm() { ...@@ -227,7 +227,7 @@ function ContactForm() {
The `shouldReset` ref ensures the cleanup only runs after a successful submission. If the user navigates away mid-draft without submitting, their input is preserved. The `shouldReset` ref ensures the cleanup only runs after a successful submission. If the user navigates away mid-draft without submitting, their input is preserved.
If you use [`useActionState`](https://react.dev/reference/react/useActionState), the same approach applies. See [Reset state](https://react.dev/reference/react/useActionState#reset-state) in the React docs for how to add a `RESET` action to your reducer. If you use [`useActionState`](https://react.dev/reference/react/useActionState), the same approach applies. See [Reset state](https://react.dev/reference/react/useActionState#reset-state) in the React docs for how to add a `RESET` action to your reducer. For more on building responsive interactions with these hooks, see the [Building interactive apps](/docs/app/guides/interactive-apps) guide.
<details> <details>
<summary>Resetting all form fields with a callback ref</summary> <summary>Resetting all form fields with a callback ref</summary>
......
...@@ -351,7 +351,7 @@ Learn more about how [routing and navigation](/docs/app/getting-started/linking- ...@@ -351,7 +351,7 @@ Learn more about how [routing and navigation](/docs/app/getting-started/linking-
### Using Server Actions in Client Components ### Using Server Actions in Client Components
You can progressively adopt Server Actions while still using Client Components. This allows you to remove boilerplate code to call an API route, and instead use React features like `useActionState` to handle loading and error states. You can progressively adopt Server Actions while still using Client Components. This allows you to remove boilerplate code to call an API route, and instead use React features like `useActionState` to handle loading and error states. See the [Building interactive apps](/docs/app/guides/interactive-apps) guide for a deeper walkthrough, including pending feedback, optimistic UI, transitions, and error handling.
For example, create your first Server Action: For example, create your first Server Action:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment