# \[PWA\] Server side rendering

**URL:** <https://forum.ionicframework.com/t/pwa-server-side-rendering/126930>\
**Category:** ionic-v3\
**Created:** [April 5, 2018, 5:34am UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930 "2018-04-05T05:34:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [April 5, 2018, 5:34am UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/1 "2018-04-05T05:34:13Z")

</div>

Is there a way to add server side rendering to a PWA built with Ionic 3?

Also is it planned out of the box for ionic-angular 4 ?

Or is the answer, “yes for both, use angular universal”?

---

<div class="post-metadata">

**Author:** ![vinicius91carvalho](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vinicius91carvalho/32/120341_2.png) [@vinicius91carvalho](https://forum.ionicframework.com/u/vinicius91carvalho)\
**Post date:** [July 8, 2018, 3:43pm UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/2 "2018-07-08T15:43:11Z")

</div>

First of all, sorry for my poor English.

After searching through Deep Web (joking), I found the solution. And the coolest solution was that I was able to integrate my Pioneer Ionic application with Firebase Hosting using Cloud Functions.

After reading the following topic:

> <https://github.com/firebase/firebase-tools/issues/33>

The @TheRoccoB user explains how to host the static Web application in Firebase Hosting and redirect traffic from a URL to Cloud Functions.

What I did was map the routes that I have to index as:

{  
“source”: “/ shop / \*\*”,  
“function”: “ssr”  
},  
{  
“source”: “/ \* / promotions / \*\*”,  
“function”: “ssr”  
}

Since “ssr” is the name of my function in Cloud Functions. So I used the library [https://github.com/prerender/prerender-node](https://github.com/prerender/prerender-node) to check if the request is from a google crowler, in case I redirect the request to a [https://github.com/prerender/prerender](https://github.com/prerender/prerender) server.

const prerender = express ();  
prerender.use (cors);  
prerender.use (  
require (‘prerender-node’)  
// .set (‘prerenderServiceUrl’, ‘http: // localhost: 3000’)  
.set (‘prerenderToken’, ‘\*\* TOKEN \*\*’)  
);  
prerender.use (require (‘prerender-node’). set (‘beforeRender’, function (req, done) {  
// do you need to do?  
console.log (‘Rendering URL:’, req.path);  
done ();  
}));  
prerender.use (require (‘prerender-node’) set (‘afterRender’, function (err, req, prerender\_res) {  
// do you need to do?  
console.log (req.path + ‘rendering completed!’);  
console.log (‘Errors:’, err);  
}));  
prerender.get (’\*’, (req, res) =\> {  
console.log (‘Calling function for URL:’, req.path);  
res.set (‘Cache-Control’, ‘public, max-age = 300, s-maxage = 600’);  
res.status (200) .send (fs.readFileSync (’./ www / index.html’). toString ());  
});  
exports.ssr = functions.https.onRequest (prerender);

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [July 8, 2018, 3:52pm UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/3 "2018-07-08T15:52:18Z")

</div>

Cool @vinicius91carvalho, thx for the tips. I would rather like not to use [pretender.io](http://pretender.io) aka would rather like to use a not costly solution but who knows, might be the only option

---

<div class="post-metadata">

**Author:** ![vinicius91carvalho](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vinicius91carvalho/32/120341_2.png) [@vinicius91carvalho](https://forum.ionicframework.com/u/vinicius91carvalho)\
**Post date:** [July 8, 2018, 5:03pm UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/4 "2018-07-08T17:03:48Z")

</div>

@reedrichards

Exists other solutions as:

- Rendertron: Rendertron is a dockerized, headless Chrome rendering solution designed to render & serialise web pages on the fly.  
[https://github.com/GoogleChrome/rendertron](https://github.com/GoogleChrome/rendertron)

- Prerender.cloud  
This is similar to [prerender.io](http://prerender.io) but more cheaper and render javascript (true SSR)  
[https://www.prerender.cloud/](https://www.prerender.cloud/)

You can host your application in [https://www.roast.io/](https://www.roast.io/) which is already integrated with prerender.cloud.

I’m searching for other solutions too.

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [July 8, 2018, 7:41pm UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/5 "2018-07-08T19:41:06Z")

</div>

Thx for the follow ups. To be really honest with you, none of them convince me that much, but like I said, maybe in last resort

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [August 31, 2018, 6:48am UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/6 "2018-08-31T06:48:39Z")

</div>

I think the Ionic team is working on something with Ionic v4

> <https://github.com/ionic-team/ionic/issues/15041>

---

<div class="post-metadata">

**Author:** ![GeoffDev](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@GeoffDev](https://forum.ionicframework.com/u/GeoffDev)\
**Post date:** [February 12, 2019, 5:53am UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/7 "2019-02-12T05:53:43Z")

</div>

Does this mean that SSR is currently not available in ionic 4? and on availability of the feature, will it be a simple upgrade or lots of configurations to get it working?

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [February 12, 2019, 6:40am UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/8 "2019-02-12T06:40:21Z")

</div>

@GeoffDev honestly I don’t know what’s the status, sorry, I didn’t search information about that since a couple of weeks

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:42pm UTC](https://forum.ionicframework.com/t/pwa-server-side-rendering/126930/9 "2021-07-19T21:42:11Z")

</div>

Closed on July 19, 2021, 9:42pm UTC


