Next.js Discord

Discord Forum

Need to run server code on each route change without using middleware

Unanswered
Harlequin posted this in #help-forum
Open in Discord
HarlequinOP
My project isn't using edge so I need to be able to run an auth check on each route without using middleware. Obviously I can just manually check on each route, but I thought template would work? Apparently template doesn't run on each route change either though.

2 Replies

personally i just made a "authcheck" function that i put on all my pages and it works good enough (i hope i havent forgotten about any places)