Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration steps for nextjs inbuilt routing #350

Open
santosh-cuemath opened this issue Apr 22, 2023 · 1 comment
Open

Migration steps for nextjs inbuilt routing #350

santosh-cuemath opened this issue Apr 22, 2023 · 1 comment

Comments

@santosh-cuemath
Copy link

Are there any easy migration step to migrate to inbuilt nextjs routing

@asjadanis
Copy link

You can use the next js rewrites in your next.config.json for this.

// next.config.json

// Existing routes configured with next-routes

const routes = require("./your-next-routes")

// Map the routes to the below shape
// routes = [{ source: '/about', destination: '/' }]


module.exports = {
  async rewrites() {
    return [...routes]
  }
}

In your server.js file delete routes import and use app.getRequestHandler()

// server.js

const handle = app.getRequestHandler();

server.get("*", (req, res) => {
    return handle(req, res);
});

Might have to delete the .next folder before giving it a go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants