Skip to content
This repository was archived by the owner on Aug 21, 2026. It is now read-only.
This repository was archived by the owner on Aug 21, 2026. It is now read-only.

Should appHistory.navigate()'s state option work for cross-document navigations? #98

Closed

Description

@domenic

I strongly suspect the answer is "no": giving a new way to pass state across documents seems a bit fraught. At the very least it'd have to be origin-constrained.

I wanted to file this issue to track this as a somewhat-open question, and get any community input. But the spec in #96 currently ignores state for cross-document navigations.

Activity

  1. tbondwilkinson commented on Apr 16, 2021

    @tbondwilkinson
    Contributor

    I'm starting to wonder whether you would ever want to use the navigate() API for a cross-origin navigation.

    Should we just throw an error if you try to do that? And create a separate api for cross-origin navigation that doesn't take anything but a url and navigateInfo?

    I think it could potentially be reasonable to pass state across documents. If you can embed something in the URL (serialize to string) you could embed it in the state object, and vice-versa.

  2. domenic commented on Apr 19, 2021

    @domenic
    CollaboratorAuthor

    I'm starting to wonder whether you would ever want to use the navigate() API for a cross-origin navigation.

    Should we just throw an error if you try to do that? And create a separate api for cross-origin navigation that doesn't take anything but a url and navigateInfo?

    Well, it'd be nice as a new "better location.assign()". I can imagine situations where you don't know whether the URL you're getting is cross-origin or same-origin, and you just want to use navigateInfo; having to parse the URL and then switch between two methods sounds less good.

  3. domenic commented on May 27, 2021

    @domenic
    CollaboratorAuthor

    Yeah, let's leave this as no...

  4. domenic commented on Aug 6, 2021

    @domenic
    CollaboratorAuthor

    I tried to write a test today that used appHistory.reload({ state: newState }), and I did not preventDefault() on the navigate event. It caught me by surprise that the state was ignored.

    But, it's probably still good to be consistent between reload() and navigate() in this sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions