Examples or documentation of how to use SSR

Is there any complete example of Node.js application that handles Aurelia SSR?

To use SSR my Aurelia application should use Webpack? Is it possible to use SSR with SystemJS Aurelia app?

My Aurelia application has a module to communicate with a backend API to get data from a database. As I understand, for SSR this module has to be completely rewritten, because my API backend is the same backend that handles SSR and I can bypass networking for my Aurelia app to access the backend API. As I can see - it is possible to configure different entry point (main.js) for server version of my app. But can’t find how to pass some object from my backend app to server version of my Aurelia app. Can I use RenderOptions or AppInitializationOptions to pass additional data (server API interface) to my aurelia app? How to access this data in aurelia app?

Is it a good idea to use Aurelia and SSR as a template engine to render static html files server side? I am using Aurelia for the frontend and I am going to add SSR to speed up frontend loading. But my backend also needs to send emails. Would you recommend rendering email html with Aurelia or it is better to use another html rendering engine?

1 Like

I think it’s not as easy to use SSR with SystemJS at the moment. Aurelia certainly can handle something like email rendering, it’s just no-one explored SystemJS SSR in v1 before, so it’s a bit unclear whats to be done for this. Can you show some code of what you have tried?

I have found complete example (backend and frontend code) that uses Aurelia SSR: https://github.com/Vheissu/aurelia-ssr-js, but I have not tested it.

The reason I asked about SystemJS, because documentation states:

In order to make it easy for you to get started with Server Side Rendering we have put together a skeleton application that already has Server Side Rendering configured.

The pre-configured SSR skeleton can be found here . Follow the instructions in the README to get started.

But there are 6 different skeletons there: GitHub - aurelia/skeleton-navigation: Starter kits for building a standard navigation-style app with Aurelia. and some use SystemJS. And I did not found any instructions in the README regarding SSR.
I think documentation should better highlight that if you want to use SSR in near future - you should start new project using webpack.

To handle email rendering using Aurelia SSR I need to pass some model (with firstName, lastName, etc…) from the backend to server side aurelia bundle. How to do that?

The other scenario when developer may need to pass object with methods from the backend to SSR frontend - is to handle database access. When frontend is run in browser - it sends REST or Web Socket requests to our backend to get data from database, when frontend is run in Aurelia SSR engine - it should access our backend directly through some javascript object with methods.