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.

Router === null on SSR

See original GitHub issue

Just when I activate the module federation on the webpack config.

The value router from const router = useRouter(); in my _app.tsx comes up as null

Any idea what could be happening?

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
noreillercommented, Jan 20, 2021

Your example doc is for a page. Here, you try to get the router from _app. It’s in the _app render props, so I would use it. This way, you don’t have to use the hoc.

import { Component } from 'react';
import { AppProps } from 'next/app';

class MyApp extends Component<AppProps> {
  render() {
    const { Component, pageProps, router } = this.props;

    return (...);
  }
}
1reaction
csi-lkcommented, Feb 5, 2021

I’m also getting this issue wether using withRouter or useRouter inside sub components, I can get the props at App level as described above but would rather not have to prop drill to every component that needs them

Running next 1.0.4, 10.0.5 or 10.0.6

I’ll update as I investigate further

Read more comments on GitHub >

github_iconTop Results From Across the Web

next 9.1.3 withRouter passes router=null on SSR #9350 - GitHub
Bug report Describe the bug withRouter passes prop router: null to wrapped component whereas in next 9.1.2 it always passed the right object ......
Read more >
nextJS SSR useRouter() does not work when refresh page
I am using nextJS SSR in my project. Now when I try to use the following code to get page parameters then it...
Read more >
Implementing SSR in Next.js: Dynamic routing and prefetching
If you find it, the page details are passed; otherwise, null is passed as a prop. Next.js doesn't allow you to pass undefined...
Read more >
next/router | Next.js
Learn more about the API of the Next.js Router, and access the router ... Here you would fetch and return the user const...
Read more >
Fixing Next.js router query param returning undefined on ...
First, let's just try to reproduce this issue. You might encounter some cases where you need access to query params of a route....
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