As of SolidJS v1.7+, the data property on RouteDefinition has been deprecated.
Background:
In earlier versions of SolidJS (especially with @solidjs/router), you might have seen route definitions like this:
<Route path="/" component={Home} data={{ title: "Home" }} />
The data property was intended to pass metadata or other information to the route component. However, this pattern was not ideal and has since been deprecated.
✅ Recommended Alternative (v1.7+):
Use the loader function to provide data for a route. This aligns better with Solid’s reactive principles and supports server-side rendering (SSR) and prefetching more cleanly.
Example:
import { FileRoutes } from "@solidjs/start";
import { createLazyFileRoute } from "@solidjs/router";
export const Route = createLazyFileRoute("/")({
loader: async () => {
return { title: "Home" };
},
component: Home,
});
Wait — actually, if you're using component-based routing, the loader is defined per route component via createRouteLoader, or in the new file-based routing (@solidjs/start), it's done via createLazyFileRoute.
Let me clarify:
If you're using file-based routing (@solidjs/start):
// routes/index.tsx
import { createLazyFileRoute } from "@solidjs/router";
import Home from "~/pages/Home";
export const Route = createLazyFileRoute("/")({
component: Home,
// No `data` here — it's deprecated.
});
To pass dynamic data, use a loader in the route module:
// routes/index.tsx
import { createLazyFileRoute } from "@solidjs/router";
import Home from "~/pages/Home";
export const Route = createLazyFileRoute("/")({
loader: () => {
return { title: "Home" }; // data accessible via route.data
},
component: Home,
});
But actually, in the current versions of @solidjs/router, loader is defined in the component file, not in the route definition.
Wait, the correct modern approach is:
✅ Use loader() inside the component file
// routes/+page.tsx (if using file-based routing)
export const loader = () => {
return { title: "Home" };
};
export default function Home() {
const data = await useLoader(); // if using within the component directly
// or use RouteData<typeof loader> if outside
return <h1>{data?.title}</h1>;
}
Wait — that's for Remix-style. Let's clarify for SolidStart + @solidjs/router:
For SolidStart (createSolidApp) with @solidjs/router:
If you're defining routes in routes/index.tsx:
// routes/index.tsx
import { createLazyFileRoute } from "@solidjs/router";
import Home from "~/pages/Home";
export const Route = createLazyFileRoute("/")({
component: Home,
});
To use loader, SolidStart recommends using the page-based API (like Remix) in +page.tsx:
// routes/+page.tsx
export const loader = () => {
return { title: "Home" };
};
export default function Page() {
const data = await useLoader();
return <h1>{data.title}</h1>;
}
So the data property in RouteDefinition is indeed deprecated.
🔍 Official Deprecation Notice
From SolidJS Router GitHub and migration notes in SolidStart:
The data option in RouteDefinition is deprecated. Use a loader function instead for route-specific data.
✅ Summary
| Feature | Deprecated? | Replacement |
|---|
data prop | ✅ Yes | loader() function |
| Route metadata | | Use loader() or context |
If you're manually defining routes using RouteDefinition, avoid using the data prop. Migrate to using loader() in the component/module instead.
Let me know if you're using @solidjs/router directly or via SolidStart, and I can tailor the example further.