remix-run / history

Manage session history with JavaScript
MIT License
8.29k stars 961 forks source link

Add Constant Domain History #962

Open JelleRoets-Work opened 1 year ago

JelleRoets-Work commented 1 year 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!