Deployments to Cloudflare Workers
Is there a particular reason why Start don't support the
cloudflare_module
preset even though Nitro supports it?
I assumed since Start is built on Nitro that it would support any presets that Nitro does out of the box.11 Replies
continuing-cyanOP•6mo ago
Or is it a Vinxi issue? The error/warning seems to be from Vinxi. The app seems to build okay and I can run it locally using wrangler, so not sure how it will work when deployed.
genetic-orange•6mo ago
it might magically disappear once we are off vinxi
continuing-cyanOP•6mo ago
Any ~ETA when v1 will be out without Vinxi? I'm busy looking at an alternative to Next.js and currently between TanStack Start and React Router v7 - leaning towards Start since it feels like it took the best parts of Next.js and RR, but also aware of the pre-v1 release. Cloudflare Workers support is important to me.
genetic-orange•6mo ago
version without vinxi will hopefully take no more than a few weeks
adverse-sapphire•6mo ago
I'm running cloudflare worker module in prod. Have run into some limitations. But overall works.
app.config.js
To get cloudflare env in dev and prod I have helper function
The only problem I'm really running is that for some reason I cannot use that in server function in loader functions. Especially beforeLoad, for some reason in that context the getEvent
evnet doesn't have the cloudflare there 😱 but when server function is called from client side it works
But as I'm running with Clerk auth that doens't really matter, as Clerk doesn't have true SSR, so the app is more or less just SPA with server functions. And most of my backend logic is deployed as trpc server else where as I have multiple different consumers.
And migrated away from RRv7. The migration from Remix was not fun. And started running into all kind of annoying issues here and there. And this comes from almost 3 years of happy remix usegenetic-orange•6mo ago
as soon as we have something testable without vinxi I will let you know so you can test with cloudflare
sharp-indigo•6mo ago
I solve it by using tanstack query:
const test = createServerFn({ method: 'GET' })
.handler(async () => {
const ctx = await getCloudflareCtx()
console.log(ctx.env.MODE)
return ctx.env.MODE
})
export const Route = createFileRoute('/_auth/dashboard')({
component: RouteComponent,
beforeLoad: async ({ context }) => {
context.queryClient.fetchQuery({
queryKey: ['test'],
queryFn: test,
})
},
})
correct-apricot•5mo ago
Can you share a repo of this?
sharp-indigo•5mo ago
I not sure is this help, but i get the code running by doing this:
I don't know why it's work, but this is the solution i got. Sorry for that i can't make this as a repo.
adverse-sapphire•5mo ago
this kind of setup was working at least some time a go https://github.com/Nipsuli/tanstack-start-cloudflare-worker
GitHub
GitHub - Nipsuli/tanstack-start-cloudflare-worker
Contribute to Nipsuli/tanstack-start-cloudflare-worker development by creating an account on GitHub.
eager-peach•3mo ago
I have it working in the latest version https://github.com/bonadio/tanstack-start-cloudflare-workers
GitHub
GitHub - bonadio/tanstack-start-cloudflare-workers
Contribute to bonadio/tanstack-start-cloudflare-workers development by creating an account on GitHub.