## router

> If you have cross-platform requirements, you can use the router object to implement your route navigation.

```js
router.push(url: string)
router.replace(url: string) // Parameters are the same as push
router.back()
router.go(delta: number)
router.reload()
```

### Introduction

```js
import { router } from '@ray-js/ray';
```

### Usage

```ts
/// routers.config.ts
import { Routes } from '@ray-js/types';

export const routes: Routes = [
  {
    route: '/',
    path: '/pages/home/index',
  },
  {
    route: '/detail/:uid',
    path: '/pages/detail/index',
  },
  {
    route: '/my',
    path: '/pages/my/index',
  },
];
```

#### push

```tsx
router.push(url: string)
```

**Hash Parameter**

```js
router.push('/detail/1234')
```

If the route configuration for the detail page is `/detail/:uid`, you can get `uid` via `location.params` after navigation.

**Query Parameter**

```js
router.push('/detail/1234?name=tuya')
```

You can get the query parameter `name` via `location.query` after navigation.

> For details on how to get page route parameters, see the [location](./location) documentation.
