#Migrating from Next to Remix

1 messages · Page 1 of 1 (latest)

celest galleon
#

I'm migrating a Nextjs app to Remix...
What should I use instead of next/link and next/router in Remix?
The app Im migrating is not mine (github.com/ndimatteo/HULL)

tropic pelican
#

remix has its own link component

bold forge
#

the useRouter equivalent is

const navigate = useNavigate()
#

oh also useLocation() for the location

stoic swan
#

You also use next/router to get the url params and such, those are divived between several react-router hooks, useLocation(), useParams(), useSearchParams()

bold forge
#

useRouter does... a lot of stuff

celest galleon
#

thanks,
If I want to match pathname with a string to see if it is "active" what should I use? useLocation()?

#

I guess useMatch() might work here

bold forge
#

generally if you want to do active styling you can use NavLink

celest galleon
#

yea I saw it but I want to use active to style a parent element

bold forge
#

otherwise it’s best to do what NavLink does internally which is basically string matching on pathname

celest galleon
#

ok, string match with pathname using useMatch()? or get pathname from useLocation()?

celest galleon
bold forge
#

you can’t

#

let me get you the link to the NavLink source

#

it uses the useLocation pathname

celest galleon
#

thanks

#

what is useMatch used for? do you have an example

bold forge
#

hmmm you know the comment makes it sound like it’s good for this too