Загрузка видео...
Не удалось загрузить видео
Here's what I'm using for RSC toast. - flash() function that server actions can call - useFlash() hook on the client that gets populated by all the server-side flash invocations Works with redirects, revalidation, progressive enhancement, etc. Blog post soon!
22,637 просмотров • 1 год назад •via X (Twitter)
Комментарии: 11

It works by the server action setting a short lived cookie that's readable by js The browser uses cookie change event and when it sees a new flash cookie it'll populate state in useFlash() Browser then immediately deletes the cookie

Small update: No more cookie change event- Cookies are read in RSC and put in client component that populates context. That was missing piece to get SSR fully functional

Discover the top Safari web extensions to boost productivity, enhance workflow, and customize your browsing experience on Mac, iOS, and iPadOS.

Awesome! Does it depend on any framework-specific features or could it theoretically be a pure React lib?

It uses cookies, so it depends on your frameworks cookie impl (ie import {cookies} form "next/headers") But maybe there's a way to make an adapter layer that hooks into all the frameworks

yep been doing exact same, so easy to do it from the server

Awesome. Thanks for sharing.

IMHO this is the way @rwieruch Convenient to use, preserves progressive enhancement

does this work similar to this?

Just why

But why?

