TanStackT
TanStack7mo ago
4 replies
primary-violet

Throwing redirect from server functions throwing an error in console and not redirecting

Hey folks,
I'm using tanstack start + solidjs. I'm trying to throw a redirect from a server function and it's throwing an error on the console.
// src/lib/auth/actions
export const login = createServerFn().handler(async () => {
  // ...
  throw redirect({ href: "http://localhost:8787" })
})
// src/routes/index.tsx
//...
<button type="button" onClick={() => login()}>
  Log in
</button>
// ...

Let me know if I'm doing something silly, otherwise I can try creating a minimal reproduction repo.
Thanks for the help in advance 🫶
image.png
Was this page helpful?