So I've been trying to make a website that would include user pages that displays their posts and other info. I'm not sure how to create new links to their accounts. For example, if a user had a UID of 121212, you could access his account information at https://www.example.com/users/121212/. Any help is appreciated.
You need to create new file in pages/users/[UID].js.
When https://www.example.com/users/121212/visit this url pages/users/[UID].js this file call.
When https://www.example.com/users/{anotherId} visit the url also pages/users/[UID].js this file call.
In users page code
import Link from 'next/link'
function Users() {
return (
<ul>
<li>
<Link href="/Users/abc">
<a>Go to pages/post/[pid].js</a>
</Link>
</li>
<li>
<Link href="/Users/abc?foo=bar">
<a>Also goes to pages/post/[pid].js</a>
</Link>
</li>
</ul>
)
}
export default Users
And in users/[UID].js file;
import { useRouter } from 'next/router'
const Post = () => {
const router = useRouter()
const { UID} = router.query
return <p>Post: {UID}</p>
}
export default Post
For more help dynamic-routes