Next.js Discord

Discord Forum

redirect all the mobile users to the /landingpage

Answered
Persian posted this in #help-forum
Open in Discord
PersianOP
Does anyone know how I can automatically redirect all the mobile users to the /landingpage when they get on my next.js website?

Or is this bad practice, because I am making a web app and it's kind of not designed for mobile, so I think it might be easier to just make a separate landing page for mobile users.
Answered by joulev
use middleware, check for the user-agent header and rewrite/redirect accordingly
View full answer

4 Replies

Answer
PersianOP
Aa, thank you,

just to clarify because I am kind of new to this. Does middleware make it such that I can make changes to what HTML document is sent to the client when they open the domain. Like a check in between like a middle man?

and will this cause a delay or SEO problems
@Persian Aa, thank you, just to clarify because I am kind of new to this. Does middleware make it such that I can make changes to what HTML document is sent to the client when they open the domain. Like a check in between like a middle man? and will this cause a delay or SEO problems
Does middleware make it such that I can make changes to what HTML document is sent to the client when they open the domain. Like a check in between like a middle man?
not really, the page handles the html. the middleware only handles what page to serve the user

and will this cause a delay or SEO problems
yes, but middleware runs on edge so is very fast, the delay is negligible in most cases
PersianOP
Ok than you for the help