question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next.js + Magic SDK V6 + OAuth Extension Fails with `TypeError: class constructors must be invoked with 'new'`

See original GitHub issue

✅ Prerequisites

  • Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
  • Are you running the latest SDK version?
  • Are you reporting to the correct repository (magic-sdk)?

🐛 Description

When initializing the client with:

export const createClientMagicInstance = () => {
  if (typeof window === 'undefined') {
    throw Error('Creating magic instance without browser window');
  }
  return new Magic(magicPublicKey, {
    extensions: [new OAuthExtension()],
  });

within Next.js, the following error is thrown class constructors must be invoked with 'new'.

This only happens when calling new OAuthExtension(). The issue is gone when downgrading to "magic-sdk": "^5.1.0"

🌎 Environment

Software Version(s)
magic-sdk 6.0.5
@magic-ext/oauth 0.9.0
next 11.1.2
Browser Firefox
yarn 16.7
Operating System MacOS

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
smithkicommented, Oct 1, 2021

@ideopunk 6.x was all about better ES module compatibility, no API changes. You can use 5.x in the meanwhile!

1reaction
smithkicommented, Sep 23, 2021

This issue has been resolved in magic-sdk@6.0.7 and @magic-sdk/oauth@0.9.2, as well as for these other extensions:

  • @magic-ext/react-native-oauth
  • @magic-ext/webauthn

Our Web3-related extensions will follow suit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next 12 Runtime TypeError: Class constructors cannot be ...
The application should run / build successfully as it did in Next 11. To Reproduce. Install next 12 / typescript: npx create-next-app@latest -- ......
Read more >
ThreeJS + NextJS: class constructors must be invoked with 'new'
I am trying to render a simple scene inside a nextJS route inside "lab2". I keep recieving this error: class constructors must be...
Read more >
Magic Link Authentication and Route Controls with Supabase ...
In this video, we'll build out a Next. js app that enables navigation, authentication, authorization, redirects (client and server-side), ...
Read more >
Next.js Authentication with Magic.link Tutorial - YouTube
I go through setup and explain the code line by line for setting up Magic.link with Next. js to authenticate users and how...
Read more >
Passwordless Authentication with Next.js, Prisma, and next-auth
In this post, you'll learn how to add passwordless authentication to your Next.js app using Prisma and next-auth.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found