link vs meta parameters #13239
-
Hi, my question is about why link helper in routes, unlike meta helper, has no parameters, it's kind of confusing to me, in my use case i have to create dynamic links and i can use meta helper arguments to create dynamic links but wondering why we don't have the same parameters for both helpers. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
MetaFunction depends on your loader data, so you can set metatags, and even link tags, based on data. LinksFunction doesn't depend on loader data, this allows the router to statically know them (not really static as it needs to call a function but that functions always returns the same links). This is useful for the router because if you use For example, if in your LinksFunction you have a link to prefetch the hero image of a route, and load some CSS file, when you render a link to to that route the router can use the result of the route LinksFunction to prefetch the image and CSS file so the next route loads immediately. If LinksFunction depended on the loader data, then it couldn't do it immediately, it would have to first fetch the data, and then use it to know what to prefetch, at that point if it already has the data it can just navigate and let the browser render the links. If you need to render |
Beta Was this translation helpful? Give feedback.
MetaFunction depends on your loader data, so you can set metatags, and even link tags, based on data.
LinksFunction doesn't depend on loader data, this allows the router to statically know them (not really static as it needs to call a function but that functions always returns the same links). This is useful for the router because if you use
<Link to="/path" prefetch="intent">Go to /path</Link>
then the router can prefetch assets you linked in your LinksFunction.For example, if in your LinksFunction you have a link to prefetch the hero image of a route, and load some CSS file, when you render a link to to that route the router can use the result of the route LinksFunction to prefetch the…