Skip to content
Source
Sign inSign up
TanStack/router

static pre-rendering does not pre-render pages that are not linked #5455

Send to my agent
ClosedFatahChan(GitHub profile, opens in a new tab) opened this issue 8 comments

Which project does this relate to?

Start

Describe the bug

I have enabled pre-render.

    tanstackStart({
      prerender:{
        enabled: true,
      }
    }),

I have the following routes

  • index.tsx
  • test1.tsx
  • test2.tsx

index route has a link to test2 route.

I expect that all routes to be pre-rendered.

actual only index, and test2 are pre-rendered.

Image

Either this a bug in the code, or the documentation is not clear

https://tanstack.com/start/latest/docs/framework/react/guide/static-prerendering

according to the documentation, that if we don't specify a specify route to be re-rendered all routes will be prerenderd

Image

Your Example Website or App

https://github.com/FatahChan/start-basic-prerender

Steps to Reproduce the Bug or Issue

run pnpm build

output would be

Image

Expected behavior

test1 should also be pre-rendered, even it's not linked in the home page

Screenshots or Videos

No response

Platform

"@tanstack/react-router": "^1.132.47", "@tanstack/react-start": "^1.132.53", "@vitejs/plugin-react": "^5.0.4", "react": "^19.2.0", "react-dom": "^19.2.0", "vite": "^7.1.9"

Additional context

No response

  1. according the comment here, only the root path is pre-rendered. https://github.com/TanStack/router/blob/main/packages/start-plugin-core/src/prerender.ts#L24

    which mean the documentation is is incorrect.

    however, I personally expect that all routes to be pre-rendered if, if no pages are specified, coming from Nextjs that would be the default behaviour

  2. we could only prerender static paths though, since dynamic paths require path params

    we don't do that but could add this

  3. we could only prerender static paths though, since dynamic paths require path params

    we don't do that but could add this

    wdym by dynamic paths?

    both test1 and test2 are static paths

  4. in your example, yes. but as soon as you add $param we can't prerender

  5. in your example, yes. but as soon as you add $param we can't prerender

    yes, I understand, my issue is that it wasn't documented properly, and was very confused.

    for now, I think that the next course of actions, is to pre-render add static routes if user did not specify pages, and improve the documentation to inform devs that dynamic paths are not pre-rendered.

    in the future, maybe something like getStaticPaths can be implemented

  6. yes, we want to add something like getStaticPaths in the future

  7. yes, we want to add something like getStaticPaths in the future

    I am working on pr to fix my issue

  8. Yeah, that's a good solutions.

Sign in to join this conversation.