Redirect from Middleware
useServerFn for the serverFn, but not sure if there's an equivalent hook that is needed for the middleware as well; currently just getting the following error in the console:Below is the code from the middleware
useServerFnreact-dom_client.js?v=a8826ad7:6490 Uncaught Error: Switched to client rendering because the server rendering errored:
{to: ..., isRedirect: true, statusCode: ...}export const authMiddleware = createMiddleware().server(async ({ next }) => {
const request = getWebRequest();
const authResp = await auth.api.getSession({ headers: request.headers });
const user = authResp?.user;
if (!user) {
throw redirect({ to: "/sign-in" });
}
return next({ context: { user } });
});You can now submit your website/app/project to http://TanStack.com 's new showcase and have it seen by the TanStack community! - Global showcase browser - Per-library filters - Category filters Submit here: https://tanstack.com/showcase/submit View all here: https://tanstack.com/showcase
dry-scarlet · 2w ago
TanStack AI Alpha 2 is here! 🖼️ Image, video, audio, speech, transcription, structured output 📦 Split adapters = smaller bundles, faster dev/contributions, easier 🎄 Fully tree shakable adapters ✨ Cleaner, flattened, fully type-safe APIs https://tanstack.com/blog/tanstack-ai-alpha-2
dry-scarlet · 4w ago
📣 TanStack AI Alpha is here! ✨ Framework agnostic 🤖 Provider agnostic 🧠 Type safe 🔧 Isomorphic tools 🛠 Devtools 🌐 Open protocol 📦 JS, Python, PHP ⚛️ React, Solid, Vanilla 🌀 OpenAI, Anthropic, Gemini, Ollama, ++ Official blog post: https://tanstack.com/blog/tanstack-ai-alpha-your-ai-your-way Docs: https://tanstack.com/ai
dry-scarlet · 2mo ago