How to execute code on start's startup ?
Hi ! I need to execute migrations and stuff on tanstack start launch, where can I do that? I tried on ssr.ts but it get executed (once, so cool) but it gets ran only when I first visit a page.
I tried to search inside the Discord, some mentionned to do that through a Nitro module/plugin, I did try, but I can't get what I need to run inside (working with cloudflare and can't get cloudflare bindings working inside it)
4 Replies
conscious-sapphire•3mo ago
here's how to https://discord.com/channels/719702312431386674/1382286680349737091/1382455765738061927 get cloudflare with bindings
conscious-sapphireOP•3mo ago
Thank you, well the cloudflare bindings are working fine inside the app itself, I'm still not using the devinxified start version, so now I get the bindings like this:
It works for now (curious about the lagging that you had tho). But what I wanted to do is to run the migrations as soon as the app starts, like is there an entrypoint of the app itself somewhere ?
conscious-sapphire•3mo ago
the lag was that i had a page that grabbed a value from kv and it would take more time to grab that value if i was also regrabbing the proxy on every refresh
i don't think there's an accesible entry point unforuntately
conscious-sapphireOP•3mo ago
Ok, I understand know, good to know then.
Well I just migrated to the devixified version because I noticed that the documentation was also updated, now server.tsx (old ssr.tsx) actually runs once as soon as when I start dev server, soooo so far so good, I didn't check when built, but it's better than before
well finally, I was wrong, I had a window open in the background and the window was reconnecting to vite so it triggered the server.tsx