Next.js Discord

Discord Forum

Seriously, how are people updating UI fast on server actions?

Unanswered
Craveri's Murrelet posted this in #help-forum
Open in Discord
Craveri's MurreletOP
Really need some help for something that probably is straight forward but I'm struggling with.
I hate the delay when re validating path and want to update the UI fast, it feels trash on my app. useOptimistic works fine for one action but what happens if I have many?
Are my users meant to cop that delay and that's the standard?
Simple things are starting to feel quite difficult compared to basic state management I previously experienced otherwise it's great.
I've implemented a custom use optimistc reducer but it's disgusting and It won't be staying haha

2 Replies

I get you @Craveri's Murrelet In my situation, I ended up using use optimistic in only one part of the my app, because I had to make an external request. So it really feels bad waiting 1~2secs for the view to update.

Now, my other forms are quite fast, some of them I use modals, then it feels fine, because we have the modal going away, the "toaster" success message, and then the datatable gets updated with the new record.

For others more complex forms I have the list and form on different pages, so its fine.
Craveri's MurreletOP
perhaps I should keep the root page as a server component for role based routing and fetch the data and manage state traditionally. For context all I'm doing is adding / updating and removing sets of an exercise. It needs to feel quick and snappy.