Can We Access Query Params in Server Side
Answered
Tramp ant posted this in #help-forum
Tramp antOP
Hi, can we access query params in server side. Like we access the /params value in server side is there an way we can access query params ?key=value in server side, without using search params is client side
const searchParams = useSearchParams();
const lid = searchParams.get("key"); Answered by Oak shoot sawfly
Yes we can access search params
interface SearchParamsProps {
searchParams: {
key: string | string[] | undefined,
};
}
export default async function Home({ searchParams }: SearchParamsProps) {
console.log(searchParams.key);
}5 Replies
Oak shoot sawfly
Yes we can access search params
interface SearchParamsProps {
searchParams: {
key: string | string[] | undefined,
};
}
export default async function Home({ searchParams }: SearchParamsProps) {
console.log(searchParams.key);
}Answer
Minor correction, it should be string | string[] | undefined
@Tramp ant thank you
Oak shoot sawfly
Welcome
@joulev Minor correction, it should be string | string[] | undefined
Oak shoot sawfly
Thanks joulev