Next.js Discord

Discord Forum

Is there an initial entry point for a Next.js application?

Answered
American posted this in #help-forum
Open in Discord
Avatar
AmericanOP
It seems to me that no code runs (that I could find) until a request is made to my site. Currently my external connections are only made once the relevant file with the connection making code is included (i.e. database.ts). To me, this seems a bit late. I would prefer to have all my necessary backend connections made already, before the first request comes in whether it be SQL, gRPC, or et cetera. The equivalent being a regular Node index.js. file My environment is not hosted on edge or any similarly short lived environments so that won't be a problem for my situation. Is there a way to do this or does anyone have recommendations for me?
Answered by Thai
what you're describing is a warmup service, i would add something to your deploy script that does an initial request at the end
View full answer

6 Replies

Avatar
Thai
what you're describing is a warmup service, i would add something to your deploy script that does an initial request at the end
Answer
Avatar
Thai
alternatively, if you can modify the server code, you could kick it off there but that's also a bit odd
Avatar
AmericanOP
It seems like with pages I could do that with server.js. Does the app router provide the same?
I guess I could technically just curl the site with deployment but I'd prefer the latter of possible
Avatar
AmericanOP
I've answered my own question in this regard. It does, but I think I'll skip the headache it looks like I'll have to endure
Thanks for the help 😄