T
TanStack4w ago
rare-sapphire

Server Start or Init functions

I plan to deploy via docker on our own infra (aws) and I'd like to run some setup script which loads secrets from a vault before the server actually starts (in next.js I used the instrumentation.ts file) - what would be the equivalent or best practice for this in "Start"?
2 Replies
other-emerald
other-emerald4w ago
you can create a nitro.config.ts file at the root of your project with this content
export default defineNitroConfig({
plugins: ['plugins/startup.ts'],
})
export default defineNitroConfig({
plugins: ['plugins/startup.ts'],
})
and a plugins/startup.ts file with this content
export default async () => {
// do your thing
}
export default async () => {
// do your thing
}
watch out though: it's NOT blocking, it runs in parallel to the server starting, not before. currently i dont think there is any way to run something before the server starts
rare-sapphire
rare-sapphireOP4w ago
thanks @notKamui - I'll try it out.

Did you find this page helpful?