SolidJSS
SolidJSโ€ข15mo agoโ€ข
2 replies
Ajso

useParams() returns params with unknown values

I'm trying to ssr a page with a dynamic parameter, but the parameters I get on the server are unknown. They are available in the preload function. Worst part is that I think this used to work a few days ago, and now it doesn't and it seems I've broken it somehow.
interface RouteProps {
  id: string
}

export const route = {
  preload: ({ params }) => getSong(params.id),
} satisfies RouteDefinition


export default function Song() {
  const params = useParams();

  console.log('params:' + JSON.stringify(params))
  const data = createAsync(() => getSong(params.id));
  ...

export const getSong = cache(async (id: string) => {
  'use server'
  const response = await api.get<GetSongResponse>(`/songs/${id}`)
  return response;
}, 'song');
Was this page helpful?