Menu
CoddyTech

Route Records

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

A route record connects a path to a component. Here /gallery selects Gallery, while / selects Lobby. The router matches the requested location and the application renders the chosen component in its outlet.

const router = createRouter({
  history: createMemoryHistory(),
  routes: [
    { path: '/', component: Lobby },
    { path: '/gallery', component: Gallery }
  ]
});

This section uses Vue 3.5.45, Vue Router 4.5.1 and later Pinia 3.0.3. The preview uses real memory history, so route changes stay inside the app and do not alter the browser address bar. The supplied bootstrap installs the router, awaits router.push('/') and router.isReady(), then mounts. Use Run preview after source edits; grading remains a separate action.

challenge icon

Challenge

Medium

Complete the route table in router.js. Map / to Home.vue, /events to Events.vue, and /help to Help.vue. The supplied views show Welcome desk, Workshop calendar and Visitor support. Each link must reach its own view and the home link must return to the first view.

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