Has anyone gotten TanStack Router/Start to work on Cloudflare Worker with bindings (NOT PAGES)
Cloudflare pages will be merging to workers, so want to know if this is something we can accomplish today
2 Replies
xenial-black•9mo ago
Mobile right now but try with this kind of config. Iirc it will deploy the way ur asking. I had this question some time ago as well
import { defineConfig } from '@tanstack/start/config'
import { cloudflare } from 'unenv'
import tsConfigPaths from 'vite-tsconfig-paths'
// import type { PluginOption } from '../../node_modules/vinxi/node_modules/vite/dist/node/index'
export default defineConfig({
vite: {
plugins: [
tsConfigPaths(),
// as PluginOption,
],
},
server: {
compatibilityDate: '2024-11-21',
preset: 'cloudflare-pages',
unenv: cloudflare,
output: {
dir: '{{ rootDir }}/dist',
publicDir: '{{ output.dir }}/public',
serverDir: '{{ output.dir }}/worker',
},
rollupConfig: {
external: ['node:async_hooks'],
},
},
tsr: {
appDirectory: './src/web',
generatedRouteTree: './src/web/routeTree.gen.ts',
routesDirectory: './src/web/routes',
/**
* This will result in the file structure:
* -> _auth/ (layout directory)
* -> layout.tsx (layout component for _auth/* routes)
* -> index.tsx (/ route)
* -> app.tsx (/app route)
*/
routeToken: 'layout',
semicolons: false,
},
routers: {
client: {
entry: './src/web/client.tsx',
},
ssr: {
entry: './src/web/ssr.tsx',
},
},
})
yammering-amber•8mo ago
@Jikyu , did you try it? Did it work?
I am also planing to deploy on Workers.