Migrating Remix loader data to a NextJs server component

December 3, 2024

Getting Pocketbase data into a component

Pocketbase setup

We will fetch our posts from pocketbase.

The Remix v2 (vite) way

In Remix we export a loader that gets the slug url segment from its params object. We return the record from that function before calling it in the component via useLoaderData.

The Next v15 RSC way

In a server component, we can make the Post itself an async function, which will depend on the Params promise resolving to get our slug url segment.

From there we can call the database directly and use its data in our markup, all in one go.

I've moved this site to Next 15 in part due to difficulties running animations in Remix v2, but I'm enjoying this RSC data loading pattern for simple reads from Pocketbase.