Getting URL params
Answered
Blue Picardy Spaniel posted this in #help-forum
Blue Picardy SpanielOP
I have a page.tsx server component. How would I get the URL? My use case is getting returned data from Discord OAuth2.
Answered by joulev
If you want the code query, simply use the searchParams prop of your page.tsx file. If you for some reasons want the entire url, you need to construct that url yourself
10 Replies
@Blue Picardy Spaniel I have a page.tsx server component. How would I get the URL? My use case is getting returned data from Discord OAuth2.
If you want the code query, simply use the searchParams prop of your page.tsx file. If you for some reasons want the entire url, you need to construct that url yourself
Answer
@joulev If you want the code query, simply use the searchParams prop of your page.tsx file. If you for some reasons want the entire url, you need to construct that url yourself
Blue Picardy SpanielOP
oh thanks, are there any docs for the props?
@joulev https://nextjs.org/docs/app/api-reference/file-conventions/page#searchparams-optional
Blue Picardy SpanielOP
what would i put as the type?
@Blue Picardy Spaniel what would i put as the type?
Record<string, string | string[] | undefined>
Blue Picardy SpanielOP
ty
You can also be a bit more specific if you like -
{ code: string; redirectTo: string }@Riday ๐ You can also be a bit more specific if you like - `{ code: string; redirectTo: string }`
It must be string | string[] | undefined. If you assert it to be a string, I can always craft a request to crash your code
@Riday ๐ You can also be a bit more specific if you like - `{ code: string; redirectTo: string }`
Blue Picardy SpanielOP
they aren't guaranteed to be there tho