Route Alias
Unanswered
Cape lion posted this in #help-forum
Cape lionOP
Hey,
I'm currently trying to achive a similar behaviour most chat apps these days have. If you open them at / this will be the "new chat page". If you type in the first message, you will be redirected to /chat/uuid or smth. Now the pages are exactly the same. I'm using Nextjs 14 and the app router. What's the best way to achive this?
I thought about something like / is just a alias to /chat/new which i could build with the directory structure. I didn't find something about route aliases tho. Whats the best practice here? Making the full page a component?
Thank you ❤️
I'm currently trying to achive a similar behaviour most chat apps these days have. If you open them at / this will be the "new chat page". If you type in the first message, you will be redirected to /chat/uuid or smth. Now the pages are exactly the same. I'm using Nextjs 14 and the app router. What's the best way to achive this?
I thought about something like / is just a alias to /chat/new which i could build with the directory structure. I didn't find something about route aliases tho. Whats the best practice here? Making the full page a component?
Thank you ❤️
1 Reply
@Cape lion Hey,
I'm currently trying to achive a similar behaviour most chat apps these days have. If you open them at / this will be the "new chat page". If you type in the first message, you will be redirected to /chat/uuid or smth. Now the pages are exactly the same. I'm using Nextjs 14 and the app router. What's the best way to achive this?
I thought about something like / is just a alias to /chat/new which i could build with the directory structure. I didn't find something about route aliases tho. Whats the best practice here? Making the full page a component?
Thank you ❤️
Bengal
sounds like some optimistic UI they do on first type, maybe try these?
https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api
https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api