[SSR] Use Recoil as state management #6188
-
Hello, I am trying to build my first Tauri App and I am trying to use Recoil as my state management. I defined my first atoms and used them in some components. But when I launch my Tauri App I get an error stating: Server Error From what I understand, this would come from the SSR of NextJS, but this started appearing when I added Recoil to my project. Are there specific instructions on how to implement Recoil in a NextJS project for correct SSR? Here are the atoms & actions I defined: https://github.com/TristanPouliquen/selection-poste-enm/blob/state-management/_state/positions.ts Here are the relevant components:
This page just fetches the list of Position objects from my backend, displays them & handles a focus to open a modal when clicking on an element. This seems to be caused by a call to Thanks in advance if anyone has an idea! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
I don't think this is necessarily Recoil's fault (well, i never heard of that lib so maybe it is) but maybe your usage of tauri's apis ( This basically means that you need to make sure that tauri's apis are only called on the client side (for example inside an componentDidMount-like useEffect hook). Edit: whoops, didn't see your last message where you basically said the same already, sorry... |
Beta Was this translation helpful? Give feedback.
I don't think this is necessarily Recoil's fault (well, i never heard of that lib so maybe it is) but maybe your usage of tauri's apis (
invoke
in this case). All of tauri's apis need access to thewindow
and some apis need thenavigator
too.This basically means that you need to make sure that tauri's apis are only called on the client side (for example inside an componentDidMount-like useEffect hook).
Edit: whoops, didn't see your last message where you basically said the same already, sorry...