Getting Started

To use Animated Router, you will need a react project. Use Create React App to create one.

$ yarn create react-app demo-app

$ cd ./demo-app

$ npx create-react-app demo-app $ cd ./demo-appo

Installation

Download the package using your favorite package manager.

$ yarn add animated-router-react

Basic Routing

Add the Navigation tag to your App component.

import Navigation from 'animated-router-react';

function App() {
        return (
        <Navigation>
        </Navigation>
);
}

export default App;

Next, add some Routes.

import Navigation, { Route } from 'animated-router-react';

function App() {
  return (
        <Navigation>
                <Route
        path="/"
        component={<>Main</>}
        />

        <Route
        path="/page1"
        component={<>Page 1</>}
        />

        <Route
        path="/page2"
        component={<>Page 2</>}
                />
        </Navigation>
        );
}

export default App;

The Route component has two required properties. 1. path is a property that defines your component address. For example, when you write in your address bar localhost:3000/page1 route with path page-1 will be displayed. The path should be a valid URL path. There are also two special paths reserved’: / and /404.

  • / means index route. This route will be displayed when you enter your page localhost:3000/ without a specific path.

  • /404 means page not found. This route is displayed if you try to open a page with a path that isn’t defined in the Navigation component. For example localhost:3000/page3.

  1. component This property defines which page will be displayed. It can be any JSX component, but if you want to animate your page during the transition, it must be a React.forwardRef component.

Styling