Menu
CoddyTech

Redirecting Old Paths

Part of the Routing and State section of Coddy's Vue journey. Lesson 26 of 55.

A redirect preserves an old entry point while selecting a canonical destination. The old record does not need its own rendered component because navigation resolves to the target record.

{path:'/old-library',redirect:{name:'library'}}
{path:'/library',name:'library',component:Library}

The resulting current path is the destination path. A function redirect can inspect the incoming location and deliberately carry query fields into the new destination. Use an alias instead only when you intend a different matching URL to remain visible; this lesson changes the location through a redirect.

challenge icon

Challenge

Medium

Support the old path /agenda by redirecting it to the named calendar route at /calendar. The destination must render Activity calendar and the route readout must show the canonical path, including after leaving for Help and using the old link again.

Keep the supplied route readout and bootstrap files.

Try it yourself

<!doctype html><html><head><meta charset="UTF-8"><title>Routing practice</title></head><body><div id="app"></div><script type="module" src="./main.js"></script></body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Routing and State