Router back button to default if no history

I have a link like this:

 <a href="#" class="link back">

if there is no history to go back to, how can i make it so the router navigates to ‘/’ or another default route? as of now the button just does nothing if there is no history.

<a href="/page1" class="link back">...</a>

1 Like