The page.tsx for /communities may change the router state while it is still rendering. This is because the component may call router.replace before the component has finished its render.
This logic should be separated to a useEffect. To keep things clean, the logic should probably be in a custom hook.