#SPA mode still server rendering even with prerendering disabled

10 messages · Page 1 of 1 (latest)

light knot
#

Hey, I'm having a difficult time getting tanstack start to work in a completely SPA like way. I am migrating a previous tanstack router app to tanstack start but it just seems to have a hard time NOT using the server. I've read all the SPA guides and done every as suggested but it still keeps getting stuck on certain local storage or context usages.

Any help is much appreciated!

#

It feels like there are many places in the codebase to say "don't use ssr" and I've tried them all. My shellComponent: RootDocument in the __root is just the basic recommended root document. I created a start.ts with

export const startInstance = createStart(() => ({
  defaultSsr: false,
}));

My vite config looks like:

const config = defineConfig({
  plugins: [
    nitroV2Plugin(),
    // this is the plugin that enables path aliases
    viteTsConfigPaths({
      projects: ["./tsconfig.json"],
    }),
    tailwindcss(),
    tanstackStart({
      spa: {
        enabled: true,
        prerender: {
          enabled: false,
        },
      },
    }),
    viteReact(),
  ],
});
grave hound
#

in the same boat with the same options currently. My child routs are still throwing Uncaught Error: Hydration failed because the server rendered HTML didn't match the client.

#

I'm also seeing:

  interface Register {
    ssr: true
    router: Awaited<ReturnType<typeof getRouter>>
    config: Awaited<ReturnType<typeof startInstance.getOptions>>
  }
}

in routeTree.gen.ts obvously this is just a type, but it does seem to conflict with the options I have set

grave hound
light knot
#

Yeah gave it a go, unfortunately I've just had to rearchitect my app a bit

#

Thanks though

grave hound
#

@light knot what did you end up having to do? I think my app is still using SSR

light knot
#

So my main issue was that my router.tsx had some useContext in it, so I had to remove that and pass that into the router later.

#

The setting in vite config + making sure the shell component were barebones make it usable