choojs / choo

:steam_locomotive::train: - sturdy 4kb frontend framework
https://choo.io/
MIT License
6.78k stars 595 forks source link

Transferring state info to/from server? #682

Closed NetOpWibby closed 5 years ago

NetOpWibby commented 6 years ago

Expected behavior

I would like to do something like, check for cookies via fastify and if found, create/update a parameter in choo's state.

Actual behavior

N/A

Steps to reproduce behavior

N/A. I haven't seen any projects that attempt to do what I've outlined but I'd love to see an example.

tornqvist commented 6 years ago

Whatever you put in window.initalState when rendering your page on the server will be picked up and used by Choo on the client.

Here's a bare bones example: https://glitch.com/edit/#!/choo-initial-state-cookie

NetOpWibby commented 6 years ago

Thank you for the example, I'll try and see if I can get something working the way I envision it. Doesn't seem like there's a way to update choo's state directly fastify without going to the front-end first.