React-moralis with Next.js

Has anyone got the react-moralis package to work with Next.js?

I am trying to do simple authentication and the metamask login does work as expected but after signing you get following response into the console:

RESTController.js:304 POST http://localhost:3000/undefined/users 404 (Not Found)

and the isAuthenticated will not be set correctly.

import React from "react";

import { MoralisProvider } from "react-moralis";

function MyApp({ Component, pageProps }) {

  return (





      <Component {...pageProps} />




export default MyApp;
import { useMoralis } from "react-moralis";

export default function Login() {

  const { authenticate, isAuthenticated } = useMoralis();

  return (


      <button onClick={() => authenticate()}>Login here</button>




Not sure if Next.js requires some additional configuration or what could possibly be the solution for this?

1 Like

Anyone having this issue… just make sure your MoralisProvider is actually getting initialized lol.


Thanks alot for the inputs. This is very helpful for other Developers! :raised_hands:

Happy BUIDLing! :slight_smile:

I have the same issue as well it has not initialized the Application and it have some kind of error message when I try to Authenticate and do something else. As follow

Hi @Xenon It doesn’t seem to me like it’s a problem because of Moralis SDK. Please create a new topic and provide us as much information as possible, including your code. Thank you :raised_hands: