Menu
CoddyTech

Replacing History

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

Replace changes the current history entry instead of adding another. If navigation has reached /draft from /, replacing it with /saved makes Back return to /.

await router.push('/draft');
await router.replace('/saved');
// History now contains / followed by /saved.

This is useful when a transient step should not be revisited with Back. A replacement still performs real navigation and renders the matched destination. Later pushes can create new entries after the replacement without restoring the overwritten entry.

challenge icon

Challenge

Medium

The supplied Details button pushes /details. Complete #finish so it replaces that entry with /complete. Pressing the supplied #back afterward must return to /, skipping the completed details step.

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