how do I run some logic on or after Nextjs starts without having to visit a route?
Unanswered
Manx posted this in #help-forum
ManxOP
Basically when you run
I want, without having to visit a route, to run some async logic.
I've tried a custom server, but it seems that a it's too much for my needs: tailwind and chadcnui stopped working after running my custom server.
I'm not concerned with customising the router, I only want to run a piece of logic without having to visit a route, be it before the Nextjs server starts or afterwards.
next dev you can't do much aside from visiting a route and then the route can be configured to do something you want.I want, without having to visit a route, to run some async logic.
I've tried a custom server, but it seems that a it's too much for my needs: tailwind and chadcnui stopped working after running my custom server.
I'm not concerned with customising the router, I only want to run a piece of logic without having to visit a route, be it before the Nextjs server starts or afterwards.
2 Replies
Cape horse mackerel
Probably you want to use https://nextjs.org/docs/app/building-your-application/routing/middleware
ManxOP
It's close thank you, but I need to run something without having to visit a route.
I figured there's no way but to lunch a script that runs both Nextjs and the other "function" — for now.
I figured there's no way but to lunch a script that runs both Nextjs and the other "function" — for now.