MFS202 : Table of Contents

Chapter 3

Lesson 2

Resource Routes: Load anything you want

Explore resource routes - the ultimate tool to serve anything you want, from PDFs to XMLs. In this lesson, you'll discover how to add resource routes to your app, and even create a sitemap using them, making your app more discoverable and SEO-friendly.

Quiz it to win it

Take the quiz

3 Questions
12 XP

Until now, our routes were only used to server UI for our app. But there are scenarios where we may need to send a different kind of response from a route rather than HTML. This can be used to serve a dynamically generated PDF or a dynamic sitemap or can act as an API route or a dynamic Open Graph image.

For instance, we can use them to serve dynamically generated PDFs, providing users with personalized documents or reports on the fly. Or, in the case of dynamic sitemaps, resource routes can help automatically update sitemap.xml files, which is crucial for SEO to reflect the latest changes in our site's content.

As API endpoints, these routes can process and respond to data requests, facilitate integration with other applications and services, or be used as a Webhook. A webhook is an HTTP-based callback function that allows lightweight, event-driven communication between web services. When a specific event occurs in one service, it triggers a notification to another service through a webhook.

Another intriguing use case is for generating dynamic Open Graph images. These are the images that appear when a link to your site is shared on social media platforms. By dynamically generating these images, we can ensure that each shared link displays an up-to-date, tailored to each page's specific content, enhancing the visual appeal and information value of shared content.

Creating a dynamic Sitemap using Resource Routes


Sitemaps are XML files that list the URLs of a website along with additional metadata about each URL (like when it was last updated, how often it changes, and how important it is relative to other URLs on the site). This information helps search engines like Google understand a website's structure and crawl it more effectively.

Get started for free today!

No commitments. No contracts. Enjoy all features for a day — join in just three clicks!

No credit card required.

Quiz it to win it

Complete this quiz successfully to proceed to the next lesson and win upto 12XP.

Start quiz for this lesson

Completing this quiz will get you

+12 Experience Points

+7% course progress