fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Define initial routes based on user agent #320

Closed ssolanki closed 1 year ago

ssolanki commented 5 years ago

I want to show a different page on the same route(/login) for mobile and desktop based on the userAgent. In my pages folder, I have two different page components login and loginMobile.

This is my routes.js file:

module.exports = routes()
// login page
.add("login")
// .add("loginMobile")

I am using express server and importing routes like this:

const routes = require("../routes")
const dev = process.env.NODE_ENV !== "production"
const app = next({ dev })
const handler = routes.getRequestHandler(app)