Have a look at stimulusreflex for example [1], the state is handled on the backend leading to you shipping less bloat to the client!
1. https://docs.stimulusreflex.com/#faster-uis-smaller-download...