DEV Community

Discussion on: Using Credentials provider with a custom backend in NextAuth.js!

Collapse
 
mnengwa profile image
mnengwa

Hi guys, the article has gotten me as far as a successful authentication, for which am grateful. However, I am unable to get the session data using getSession() or useSession() client-side for which they both return null. What are the possible causes of the bug/issue?

Collapse
 
twisha profile image
Twisha • Edited

Have you added the Provider in your _app.js ?

import { Provider } from 'next-auth/client'

export default function App ({ Component, pageProps }) {
  return (
    <Provider session={pageProps.session}>
      <Component {...pageProps} />
    </Provider>
  )
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
hrghafoori profile image
HamidReza Ghafoori

for me it returns undefined.
Did you solve your problem? If yes, can you explain me how?