#Using Zustand with inertiajs

1 messages · Page 1 of 1 (latest)

scenic dagger
#

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?

sand shell
#

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.

scenic dagger
#

@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.

sand rampart
sand shell
# scenic dagger <@126645623842668545> Thank you for your reply. Exactly, my concern is this par...

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

scenic dagger