title: How to use Cloud Functions for Firebase to prerender pages for SEO?
body: <p>The Cloud Functions for Firebase documentation <a href="https://firebase.google.com/docs/hosting/functions" rel="noreferrer">here</a> states that this can be done using cloud functions -</p>
  
  <blockquote>
    <p>Prerendering for single page apps to improve SEO. This allows you to create dynamic meta tags for sharing across various social networks.</p>
  </blockquote>
  
  <p>There are 2 questions I have:</p>
  
  <ul>
  <li><p>Can someone explain with an example how pre-rendering is achieved? </p></li>
  <li><p>How does this work in conjunction with Firebase Hosting? So let's say I have a webpage at <code>xyz.com/salon/43</code> and in Firebase hosting I have a salon.html which is served in response to this request. Now in order to be able to prerender should I move from hosting to a cloud function which renders the webpage? In other words do I go from</p>
  
  <pre><code>"rewrites": [{
      "source": "/salon/*",
      "destination": "/salon.html"}]
  </code></pre>
  
  <p>to </p>
  
  <pre><code>"rewrites": [{
      "source": "/salon", "function": "salon"}]
  </code></pre></li>
  </ul>