#What is the expected behaviour of ssr:false

7 messages · Page 1 of 1 (latest)

candid quartz
#

I asked a previous question that ssr:false breaks vinxi. I now use https://tanstack.com/router/v1/docs/framework/react/examples/basic-ssr-file-based as my starting point so i only run "node server.js".
My entry-server.tsx is also identical. As soon as i set ssr:false on a route it is correctly not rendered on the server, but it is also not rendered on the client so it never appears. Do i need to declare the route differently?
This does not render anything:

import { createFileRoute } from "@tanstack/react-router";

export const Route = createFileRoute("/about")({
    component: About,
    ssr: false,
});

function About() {
    return <div className="p-2">Hello from About!</div>;
}

An example showing how to implement Basic Ssr File Based in React using TanStack Router.

candid quartz
#

Hm I am now running the exact example locally (checked out the repo) and can't reproduce this. however slightly adapting the component, the text "this is a server component" is still briefly visible, so SSR is not really disabled?

I am still on react 18 and have react-router (v7) still installed (exploring the migration), could that be a problem?

import { createFileRoute } from '@tanstack/react-router'
import * as React from 'react'

export const Route = createFileRoute('/error')({
  component: ErrorComponent,
  ssr: false,

})

function ErrorComponent() {
  const isServer = typeof window === 'undefined'
  return (
    <div className="p-2">
      <h3>The loader of this page has a 50% chance of throwing an error!</h3>
      {isServer && <p>This is a server component</p>}
    </div>
  )
}

#

oh an important piece of information: i am actually just using start for SSR and want to stick with tanstack/router for now

candid quartz
#

I found my issue. The Quick start does not specify to add the <Script/> tag here: https://tanstack.com/router/v1/docs/framework/react/quick-start#srcroutes__roottsx
Neither does the SSR guide, so you end up without it, but it is required for SSR to work.

If you're feeling impatient and prefer to skip all of our wonderful documentation, here is the bare minimum to get going with TanStack Router using both file-based route generation and code-based rout...

frail lotus
frail lotus
#

if you want server capabilities, check tanstack Start