T
TanStack3mo ago
apparent-cyan

createFileRoute removed on save

Trying to migrate from Next.js, running the alpha. Running into two issues with file based routing: 1. No createFileRoute being inserted in existing files 2. With new files, createFileRoute is added, but when saving the createFileRoute import is removed
"@tanstack/react-router": "1.121.0-alpha.14",
"@tanstack/react-start": "1.121.0-alpha.21",
"@tanstack/react-router": "1.121.0-alpha.14",
"@tanstack/react-start": "1.121.0-alpha.21",
Vite config
import tailwindcss from "@tailwindcss/vite"
import { tanstackStart } from "@tanstack/react-start/plugin/vite"
import { defineConfig } from "vite"
import tsconfigPaths from "vite-tsconfig-paths"

export default defineConfig({
server: {
port: 3000,
},
plugins: [tailwindcss(), tsconfigPaths(), tanstackStart()],
})
import tailwindcss from "@tailwindcss/vite"
import { tanstackStart } from "@tanstack/react-start/plugin/vite"
import { defineConfig } from "vite"
import tsconfigPaths from "vite-tsconfig-paths"

export default defineConfig({
server: {
port: 3000,
},
plugins: [tailwindcss(), tsconfigPaths(), tanstackStart()],
})
8 Replies
foreign-sapphire
foreign-sapphire3mo ago
yes, this is expected. you dont import createFileRoute anymore this will be much smoother soon
apparent-cyan
apparent-cyanOP3mo ago
Thanks, how do we deal with the TypeScript part then? Create a global or something?
foreign-sapphire
foreign-sapphire3mo ago
it's done for you automatically no need to worry about that
apparent-cyan
apparent-cyanOP3mo ago
It seems that this only works for 1 file for me. In my index.tsx I dont need the import. In other files it will give me a missing definition error. Also, is there a way to fix #1? It seems that Vite is not adding export const Route ... to files that already existed
foreign-sapphire
foreign-sapphire3mo ago
we only prefill empty files so you would need to add the export yourself. should be picked up then .
apparent-cyan
apparent-cyanOP3mo ago
Fair enough, thanks!
foreign-sapphire
foreign-sapphire3mo ago
however the code generator is currently being rewritten by me to me much more robust. will be out soon
apparent-cyan
apparent-cyanOP3mo ago
Nice! Looking forward to it Thanks for the help

Did you find this page helpful?