NextRouter was not mounted
Answered
Flemish Giant posted this in #help-forum
Flemish GiantOP
Trying to check if a user is AlphaUser or not. Back-end dev is still implementing this so currently just using static variable (bare with me)
I get this error though:
"use client";
import { useEffect } from 'react';
import { useRouter } from 'next/router';
const Home = () => {
const isAlphaUser = true; // Replace this with the actual check once the API is ready
const router = useRouter();
useEffect(() => {
// Check if the user is not an alpha user
if (!isAlphaUser) {
// Redirect to the /alpha route
router.push('/alpha');
}
}, [isAlphaUser, router]);
return (
<main>
{/* Your main content goes here */}
</main>
);
};
export default Home;I get this error though:
14 Replies
Flemish GiantOP
ah
thank you 🙠@riský
beside this, this a good enough check?
tbh its a common issue that people have
@riský tbh its a common issue that people have
Flemish GiantOP
the error message should include that fix tbh
@Flemish Giant beside this, this a good enough check?
i mean, if server component, you can bypass client and just use
redirect from next/navigationFlemish GiantOP
even though it links to the docs which say it i'm just dumb ðŸ˜
client component
its the user dashboard
yeah thats fine
Flemish GiantOP
great, thank you so much
have a nice day
you tooo :)))