next-router-migration
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

next-router-migration

A simple and light-weight react-router plugin for Next.js applications.

  • Zero dependencies
  • 🦄 TypeScript support

Although next-router-migration supports only essential react-router properties, it would be enough for most websites.

If you need advanced react-router hooks or component, you are welcome to contribure

This repository is here only to help you to migrate to NextJS easely and remove step by step your legacy code

Install

$ npm install next-router-migration
# or with yarn
$ yarn add next-router-migration

Usage

Add next-router-migration alias in your next.config.js file

Example:

// next.config.ts
module.exports = {
  webpack: config => ({
    ...config,
    resolve: {
      ...config.resolve,
      alias: {
        ...config.resolve.alias,
        'react-router-dom': 'next-router-migration'
      }
    }
  })
}

Add your routes paths and redirect in your config to replace your Router file but t's optional

// next.config.ts
module.exports = {
  rewrites: async () => [
    {
      source:
        '/my-custo-routes',
      destination:
        'home-my-custom-routes',
    },
}

There are 2 options to configure default SEO properies.

Add your routes in pages/*.tsx

you can now run your code keep or remove react-router-dom in your codebase and replace it with next/router

Readme

Keywords

Package Sidebar

Install

npm i next-router-migration

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

17.5 kB

Total Files

10

Last publish

Collaborators

  • benjipott