Can't Authenticate with React moralis

Hello Everyone,

Just Started learning about Moralis, i just wanted to try doing a doing a conditions if isAuthenticated show the text but it doesn’t, i had take the moralis docs example to start but didn’t work anyway :

import React, { useEffect } from "react";
import { useMoralis } from "react-moralis";
// import Navigations from "./routing/Navigations";
import "./styles/styles.scss";

const App = () => {
  const { authenticate, isAuthenticated, user, Moralis } = useMoralis();

  if (!isAuthenticated) {
    return (
        <button onClick={() => authenticate()}>Authenticate</button>

  return (
      <h1>Welcome {user.get("username")}</h1>
  // return <Navigations />;

export default App;

import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import { MoralisProvider } from "react-moralis";

      <App />

of course i put the key and the serverUrl in my app

when i click on authenticate it goes to the metamask window, ask me to sign when i sign the window go back to my component but doesn’t display text as if i was authenticate

no error message and if i console log isAuthenticated after is the value is False.

Thanks for your future help !

1 Like

Hey @JonnyDev

I’ve tried your code and it works fine

Try to add logout button and repeat athenticating:

return (
      <h1>Welcome {user.get("username")}</h1>
      <button onClick={() => logout()} disabled={isAuthenticating}>

Thanks for your help, but my problem was that i was on localhost (-_-) lol… sorry

Hey @JonnyDev

It’s okay.
Happy BUIDLing :man_mechanic:

Thanks your very much !