Redirects not working as shown in Start docs
I'm following this page: https://tanstack.com/router/latest/docs/framework/react/start/server-functions#redirects
It includes this code for redirects:
However, that gives the error
The code then works, but I get a TS error: Since it's working I'm ok for now, but I'm wondering which is correct... is there supposed to be a redirect function in ts/start that differs from the one in ts/react-router? Here are my deps in case it helps answer:
Module has no exported member redirect .
. I can instead import redirect
from @tanstack/react-router
.The code then works, but I get a TS error: Since it's working I'm ok for now, but I'm wondering which is correct... is there supposed to be a redirect function in ts/start that differs from the one in ts/react-router? Here are my deps in case it helps answer:
7 Replies
correct-apricot•12mo ago
That's our bad. We'll fix the docs.
redirect
is exported by @tanstack/react-router
adverse-sapphireOP•12mo ago
Ok, thanks for confirming @Sean Cassiere!
Any thoughts on why I'm getting the TS error I mentioned?
This is my server function (based on Clerk docs for Start):
The
to: '/'
gets underlined looking for a "search" property that doesn't seem to exist. This code works as-is though, and the redirect to "/" functions as expected... the file's just red showing an error.
I've tried things like rerunning the app, restarting the TS server, changing to the workspace version of TS, restarting VS Code, deleting node_modules, etc. Not sure what it could be since it looks ok to me and works as expected.adverse-sapphireOP•12mo ago
Pic of the full message

adverse-sapphireOP•12mo ago
And when I run the code and try to visit the route with the auth check the redirect runs correctly... here's the server console output:
there are quite a few 'conflicting' and 'could not resolve' errors/warnings when running 'npm i' on the basic TS Start app, so the error might be coming from a mismatch related to that
correct-apricot•12mo ago
Does your index route expect search params?
Either ways, upgrade to latest
adverse-sapphireOP•12mo ago
No search params, although I will double-check my setup (just copied the quickstart docs though). I’ll also play with versions, although ‘npm outdated’ doesn’t list anything.
No worries right now since Start is Alpha and it’s functional, just thought there might be something obvious I missed.
correct-apricot•12mo ago
It is possible that its a version mismatch, since its working fine in the examples