---
title: "Serving dynamic content with Cloud Functions on Firebase Hosting"
description: "Serving dynamic content with Cloud Functions on Firebase Hosting"
published: "2017-06-07"
last_updated: "2017-06-07"
authors:
  - "Michael Bleigh (Engineer)"
categories:
  - "Hosting"
  - "Cloud Functions"
  - "Web"
  - "Launch"
canonical_url: "https://firebase.blog/posts/2017/06/serving-dynamic-content-with-cloud"
---

# Serving dynamic content with Cloud Functions on Firebase Hosting

*Published June 7, 2017 by Michael Bleigh (Engineer)*

---
[Three years ago](https://firebase.googleblog.com/2014/05/introducing-firebase-hosting.html), we launched Firebase Hosting to make it easier for developers to deliver fast, engaging experiences on the web. [Two months ago](https://firebase.googleblog.com/2017/03/introducing-cloud-functions-for-firebase.html), we launched the beta of Cloud Functions for Firebase to let developers write custom backend logic without having to worry about servers or infrastructure. More recently at Google I/O, we brought Firebase Hosting and Cloud Functions together to provide a flexible set of tools to build Progressive Web Apps with world-class scale and performance.

You can connect an HTTPS Cloud Function to your Firebase Hosting app by adding a rewrite to the `firebase.json` configuration for your project:

```json
{
  "hosting": {
    "rewrites": [
      {"source": "/function/**", "function":"myFunction"}
    ]
  }
}
```

Once connected, matching requests seamlessly proxy to your Cloud Function (in the example above, a function named `myFunction`). This one-line change enables exciting new capabilities for Firebase Hosting users including:

1.  **Server-Side Rendering.** Until now, Firebase Hosting has only served static content. Now you can serve dynamic content using industry-standard libraries like [Express](http://expressjs.com/), while still leveraging a lightning-fast global CDN cache.
2.  **Custom APIs.** With Cloud Functions and Firebase Hosting, you can create custom API endpoints on your own domain, avoiding the overhead of cross-origin requests. Plus, with a few extra [lines of code](https://github.com/firebase/functions-samples/tree/master/authorized-https-endpoint) you can authorize your endpoints through Firebase Auth.
3.  **User-Generated Web Content.** For the first time, Firebase Hosting can generate content compatible with [AMP](https://www.ampproject.org/), [Twitter Cards](https://dev.twitter.com/cards/overview), and more without requiring a deploy. This means your Firebase Hosting apps can be more shareable and more searchable than ever before.

For Cloud Functions users, you can now run functions on an SSL-secured custom domain and get powerful caching to avoid unnecessary executions.

To get started using Cloud Functions on Firebase Hosting for your own Firebase project, take a look at our [documentation](https://firebase.google.com/docs/hosting/functions). You can also learn more in our I/O session: [Building Fast Web Experiences with Firebase Hosting](https://www.youtube.com/watch?v=R3v8EcYzf_M&feature=youtu.be&list=PLl-K7zZEsYLma7gxYxtEwO1rsAPn7wkV_).
