DEV Community

Discussion on: Component-level data fetching in Sitecore JSS with Next.js

Collapse
 
mattyh profile image
Matt Hopkins

Nice explanation and example, but one obvious question is, how do we pass any parameters to the Get..Props functions to control what we are passing to the API call?
for example, we might want to ask for a url with record id so calling myapi.com/api/getRecord?recId=X
So how do we pass in a value for X? or if this isn't possible, how do we get the query params inline from the current URL? I tried
const searchParams = useSearchParams();
const params = searchParams.get('params'); // e.g. 123
but the GetStaticComponentProps function blows up!