Skip to content

Issue when using the Magic Link feature in a Next.js project #212

Open
@mcdermc

Description

@mcdermc

Hi,
I am using the Magic Link feature in a Next.js project.
I can input the email address to which I want to receive the magic link, and I receive the Magic link in an email.
But when I click on the magic link I get the following error in the browser interface (and the website does not load):
image

The issue is with this function:

export function removeFragmentIdentifierFromBrowserLocation() {
const { history } = configure();
history.pushState("", "", currentBrowserLocationWithoutFragmentIdentifier());
}

When I change line 82 from this:
history.pushState("", "", currentBrowserLocationWithoutFragmentIdentifier());
to this:
history.pushState(null, "", currentBrowserLocationWithoutFragmentIdentifier());

then the Magic Link works perfectly, with no errors.

This is because Next.js expects the first parameter of history.pushState to be either an object or a null value, not an empty string.

It would be great to have the npm package updated so I don't have to maintain my own fork of the code just for this small change.
However, I don't know if this change could have a negative impact when using other frontend frameworks.

By the way, congratulations on creating this really useful project, with excellent documentation. Huge credit is deserved.

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