remix-run / history

Manage session history with JavaScript
MIT License
8.3k stars 960 forks source link

Add Constant Domain History #962

Open JelleRoets-Work opened 2 years ago

JelleRoets-Work commented 2 years ago

This PR adds a new 'Constant Domain History' object.

Why

Currently when navigating back and forth with the history object, you don't know upfront where this will bring you. So you might as well end up on a different domain, which is often unexpected / unwanted.

What

The newly added history object prevents going back to a different domain.

How

By setting a fromDomain flag in the history state. See the extended docs in this PR for further details.

Impact

It slightly modifies the existing interface of the History object, but it is still backwards compatible. The navigation functions now return a boolean if the navigation was blocked or not.

State

This is an initial PR, I don't expect it to get merged as is, but I'd love to gain some feedback / insights from the community!