Next.js Discord

Discord Forum

Can't get token from URL

Answered
Western thatching ant posted this in #help-forum
Open in Discord
Western thatching antOP
localhost:3000/auth/1234

In my app/auth/[token]/page.tsx
export default function Page({ params }: { params: { token: string } }) {
return <div>My Post: {params.token}</div>;
}
Result -> params.token = 1234.

localhost:3000/auth/1234?code=123
The auth callback appends ?code=123.... to the URL
The '?' is messing up my ability to get the code. Anyone familiar with this?
Answered by Ray
export default function Page({
  params,
  searchParams,
}: {
  params: { slug: string }
  searchParams: { [key: string]: string | string[] | undefined }
}) {
  return <h1>{searchParams.code}</h1>
}
View full answer

2 Replies

Answer
Western thatching antOP
Boss!