aws-amplify / aws-amplify/docs

gen2/start/quickstart/nextjs-app-router-server-components displays wrong function to use on client side

Open
#6,880 0 comments 1 reaction 0 assignees View on GitHub
amplify/js
Dominant language
MDX
Stars
506
Forks
1.1k
Avg merge
3h 14m
Merged PRs (30d)
1

Description

**Describe the content issue**:
At this point in the documentation in the code provided you use

```// components/Login.tsx
"use client";

import { withAuthenticator } from "@aws-amplify/ui-react";
import { AuthUser } from "aws-amplify/auth";
import { redirect } from "next/navigation";
import { useEffect } from "react";

function Login({ user }: { user?: AuthUser }) {
useEffect(() => {
if (user) {
redirect("/");
}
}, [user]);
return null;
}

export default withAuthenticator(Login);
```

However according to nextjs documentation [here](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#userouter-hook) you should use either useRouter hook or the Link component to accomplish this because this component is a client side component. Pretty minor issue, but thought I'd report it nonetheless.

**URL page where content issue is**:
https://docs.amplify.aws/gen2/start/quickstart/nextjs-app-router-server-components/#add-server-authentication-routes

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.