Hi everyone,
I'm going to build a project with Laravel, React, some react libraries like ReactFlow (for a complex node based ui)
I want to use Inertia so bad but in some part of application I need to use some State Manager like Zustand to handle the state in complex node based ui.
I was wondering if its okay to use a state manager in some parts of a inertiajs application or If that need could'nt be taken care of with server side state only, then inertia is not a good choice?
#Using Zustand with inertiajs
1 messages · Page 1 of 1 (latest)
I'm mostly using Vue, so I'm commenting with regards to that. Vue also has a state management library (Pinia), but since Inertia is server-driven it kinda clashes with that. I have used Pinia in smaller parts of an Inertia app, but not as the main "driver" so to speak.
@sand shell Thank you for your reply.
Exactly, my concern is this part "but since Inertia is server-driven it kinda clashes with that". I love inertia and how it works but I really need that state management for a small(but complex) portion of my app.
So I'm worried about Zustand (Which is in my opinion very simillar to Pinia) interfere with inertia.
Can’t you work around that using for example the local storage if it’s that small of a portion you need?
Yeah, it's basically a shift in responsibilities. Like with Pinia the source (client-side) is kinda the source of truth. You'd request data through the store, you'd do things like user.fetch() to update the user-data, through an API. With Inertia this data is already populated. Honestly haven't explored it too much, just in a few isolated parts. Perhaps you could also just populate the store from usePage(), although updating the store becomes a whole different thing, reloading pages etc
Actually I haven’t thought of local storage. To be honest its a node base ui in which default behaviour of some elements are based on state management by defualt.
So thank you for pointing this out. I will keep that in my mind as a backup plan to use local storage as a work around.
Thank you