T
TanStack•2mo ago
equal-aqua

[TanStack Router] SSR import error

Hey! I'm trying to implement SSR using the TanStack Router following this guide: https://tanstack.com/router/latest/docs/framework/react/guide/ssr However, I'm running into an import error right at the start:
import {
createRequestHandler,
renderRouterToString,
RouterServer,
} from '@tanstack/react-router/ssr/server'
import {
createRequestHandler,
renderRouterToString,
RouterServer,
} from '@tanstack/react-router/ssr/server'
And the error I'm getting is:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './ssr/server' is not defined by "exports" in /node_modules/@tanstack/router-core/package.json imported from /node_modules/@tanstack/react-router/dist/esm/ssr/server.js
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './ssr/server' is not defined by "exports" in /node_modules/@tanstack/router-core/package.json imported from /node_modules/@tanstack/react-router/dist/esm/ssr/server.js
Just wanted to confirm: is @tanstack/react-router/ssr/server still a valid import path in the latest version? Or has it moved/been changed? I'm using the latest version of @tanstack/react-router. "@tanstack/react-router": "^1.127.3", Thanks in advance!
SSR | TanStack Router React Docs
[!WARNING] While every effort has been made to separate these APIs from changes to Tanstack Start, there are underlying shared implementations internally. Therefore these can be subject to change and...
4 Replies
like-gold
like-gold•2mo ago
what version of router-core do you have installed? cc @Nico Lynzaad
foreign-sapphire
foreign-sapphire•2mo ago
Hi @Marko it is still a valid export. You can have a look at the ssr examples where it is being used, the docs should be in line with these. The chances are that it's an old dependency that is giving you trouble, so probably start by nuking your node_modules and reinstalling the packages. If you can share your package.json or link to a github or stack blitz example I will be able to assist in about an hour.
equal-aqua
equal-aquaOP•2mo ago
Hey guys, thanks for the quick help! Not sure what exactly fixed it, but I did another rm -rf node_modules and updated all the TanStack Router-related packages to the latest versions: @tanstack/react-router @tanstack/router-core @tanstack/router-devtools @tanstack/router-plugin @tanstack/router-vite-plugin I also had to restart the Vite dev server. After that, everything started working. 🙌
foreign-sapphire
foreign-sapphire•2mo ago
great. just on a side note router-core is a dependency of react-router so probably don't need that directly

Did you find this page helpful?