Serverside rendering without API calls

Hi everyone!

Recently I’ve completed Mike North’s amazing Ember course on Frontend Masters. I really liked Ember and would like to rewrite one of my “oldschool” website into it.

My question is: if I want to make the initial load of my app SSR do I have to use Ajax calls or can I load my data some different way in Ember?

Currently my app makes a few SQL query then renders the site. Making this with API calls seems to be overhead.

Yes, to convert your site to a single-page app (whether using Ember or any other Javascript framework) you will probably need to expose an API.

It would be possible (though weird), to add some fastboot-only code that makes SQL queries to your database. But the problem is, fastboot is only serving the first hit to your site. Once a visitor is on the site, the app boots in their web browser, and as they navigate around they’re going to need to load more data, and the code that’s asking for the data is in their web browser, not on your server.

That’s what I’m after. Currently the site works like this; after the page loaded with the initial data, I do AJAX calls to update the site.

This is my site. (Sorry it’s in Hungarian)

After the page loaded, the users can choose news sites (sidebar) and categories (secondary header) and when they do, I update the site with an ajax call.

Then you are nearly done. Since you’ve already implemented the server that handles the ajax calls, you have no extra work to do. Just make sure the fastboot server can also make those ajax calls to the API server.

This is the preferred solution because it means you don’t need to implement everything two different ways.