Search code examples
ember.jsember-dataember-cliember.js-fastboot

Models in ember-fastboot loaded twice


An ember-cli app loads a random model on a certain page. This works as expected.

Now that I enabled ember-fastboot server-side rendering, the model is loaded client-side.

Upon rehydration, ember.js loads a random model again, client-side. This causes the page upon opening to show one model for part of a second (depending on internet speed), and then it changes.

I am guessing that the model needs to be loaded client-side for all client-side functionality that needs the model to be loaded.

Is it possible to prevent fetching a new random model on first pageview right after fastboot? How do I prevent a model from being reloaded client-side?


Solution

  • What you’re looking for is known as the “shoebox”. Fastboot has a service you can use that will help transfer preloaded state on the backend to your client. More details here: https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/README.md#the-shoebox