{JSON.stringify(routePaths, undefined, 2)}
```
Example output:
```
{
"home": "/"
"about": "/about",
"login": "/login",
"signup": "/signup",
"forgotPassword": "/forgot-password",
"resetPassword": "/reset-password",
"newContact": "/contacts/new",
"editContact": "/contacts/{id:Int}/edit",
"contact": "/contacts/{id:Int}",
"contacts": "/contacts",
}
```
## useRoutePath
Use this hook when you only want the path for a single route. By default it
will give you the path for the current route
```jsx
// returns "/about" if you're currently on https://example.org/about
const aboutPath = useRoutePath()
```
You can also pass in the name of a route and get the path for that route
```jsx
// returns "/about"
const aboutPath = useRoutePath('about')
```
Note that the above is the same as
```jsx
const routePaths = useRoutePaths()
// returns "/about"
const aboutPath = routePaths.about
```
## useRouteName
Use the `useRouteName()` hook to get the name of the current route (the page
the user is currently visiting). The name can then also be used with `routes`
if you need to dynamically get the url to the current page:
```jsx
const routeName = useRouteName()
const routeUrl = routeName ? routes[routeName]() : undefined
```
## Navigation
### navigate
If you'd like to programmatically navigate to a different page, you can simply use the `navigate` function:
```jsx title="SomePage.jsx"
import { navigate, routes } from '@cedarjs/router'
const SomePage = () => {
const onSomeAction = () => {
navigate(routes.home())
}
...
}
```
The browser keeps track of the browsing history in a stack. By default when you navigate to a new page a new item is pushed to the history stack. But sometimes you want to replace the top item on the stack instead of appending to the stack. This is how you do that in Redwood: `navigate(routes.home(), { replace: true })`. As you can see you need to pass an options object as the second parameter to `navigate` with the option `replace` set to `true`.
By default `navigate` will scroll to the top after navigating to a new route (except for hash param changes), we can prevent this behavior by setting the `scroll` option to false:
`navigate(routes.home(), { scroll: false })`
### back
Going back is as easy as using the `back()` function that's exported from the router.
```jsx title="SomePage.jsx"
import { back } from '@cedarjs/router'
const SomePage = () => {
const onSomeAction = () => {
back()
}
...
}
```
## Blocking
### useBlocker
The `useBlocker` hook allows you to prevent navigation away from a page under certain conditions. This is useful for scenarios such as preventing a user from accidentally navigating away from a form with unsaved changes.
```jsx
import { useBlocker } from '@cedarjs/router'
import { useForm } from '@cedarjs/forms'
const SomeForm = () => {
const form = useForm🤦♂️ Oops.
Sorry about that. Please contact support for help.
404
Check the URL in the address bar and please try again.