Next.js Discord

Discord Forum

how to achieve something similar to useHref hook in next js.

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
https://remix.run/docs/en/main/hooks/use-href

It is crucial when working with nested layout to figure out parent path url to construct further nested url?

2 Replies

Polar bearOP
it always return the till current leaf path, not the path associated with nested level.
For Eg:
<Parent path="/">
  <Level-1 path="level1">
     // usePathname gives /level1/level2 instead of /level1
     <Level-2 path="level2">
          // usePathname gives /level1/level2/
          <Children>
      </Level-2>
  </Level-1>
</Prent>