TanStackT
TanStack2mo ago
28 replies
dead-brown

SSR disabling doesn't work

I'd like to generate blog during the build and never refetch this data again (SSG / prerender or however u wanna call it)

With this configuration every after running pnpm build && pnpm serve each request still triggers this 5s timeout so ssr wasn't disabled for some reason. Am I doing something wrong?
export const Route = createFileRoute("/blog")({
    component: RouteComponent,
    ssr: false,
    loader: async () => {
        console.log("loading blog route");
        await new Promise((r) => setTimeout(r, 5000));
        return [
            {
                title: "Blog",
                description: "Blog description",
            },
            {
                title: "Blog 2",
                description: "Blog description 2",
            },
            {
                title: "Blog 3",
                description: "Blog description 3",
            },
        ];
    },
});


import { defineConfig } from 'vite'
import { devtools } from '@tanstack/devtools-vite'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import viteReact from '@vitejs/plugin-react'
import viteTsConfigPaths from 'vite-tsconfig-paths'
import tailwindcss from '@tailwindcss/vite'
import { nitro } from 'nitro/vite'

const config = defineConfig({
  plugins: [
    devtools(),
    nitro(),
    // this is the plugin that enables path aliases
    viteTsConfigPaths({
      projects: ['./tsconfig.json'],
    }),
    tailwindcss(),
    tanstackStart({
      prerender: {
        enabled: true,
        filter: ({ path }) => path.includes('blog'),
      },
    }),
    viteReact({
      babel: {
        plugins: ['babel-plugin-react-compiler'],
      },
    }),
  ],
})

export default config
Was this page helpful?