goatslacker / alt

Isomorphic flux implementation
http://alt.js.org/
3.45k stars 323 forks source link

Isomorphic application with authentication! #624

Closed sergeysova closed 8 years ago

sergeysova commented 8 years ago

I use react-router. I want make server-side rendering on React with Alt. I want load all data before rendering on server. Ex.: authenticate by JWT How can i do that?

goatslacker commented 8 years ago

Authenticate using JWT. Use alt.bootstrap to load all the data into your stores. Render your components.

goatslacker commented 8 years ago

http://alt.js.org/docs/bootstrap/

sergeysova commented 8 years ago

@goatslacker what if i have so many data in db?!

sergeysova commented 8 years ago

for example:

in react router i have search page

<Route path="/search/:query" component={SearchComponent} />

I want return rendered component with founded data.

Another example: get friend list

sergeysova commented 8 years ago

I don't want to write crutches, ex: create many express routes special for react-router routes. Because i already have API

goatslacker commented 8 years ago

I'm not sure what your application stack looks like. If you want to share API calls between server and client then you'll need to create and pass around instances of flux per request so you don't have data collisions. If you already have all the data then you can safely bootstrap/flush it on each request.