You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Start hydration issue with localized head meta title using Lingui i18n #4279
import{i18n}from"@lingui/core";import{msg}from"@lingui/core/macro";exportconstRoute=createFileRoute("/")({component: Home,head: ()=>{return{meta: [{title: i18n._(msg`Test English title`),},],};},});
Before hydration, the SSR render is all correct. The page title is localized and the content is correct.
After hydration, the contents appears twice, the top appears to be the SSR version (clicking links will load pages), the bottom appears to be the hydrated client (clicking links do not load pages). The localized title also does not work because there are two <title> in the HTML
<head><title>TanStack Start | Type-Safe, Client-First, Full-Stack React Framework</title><title>Test English title</title>
There are also no hydration errors in the console.
I haven't been following the alpha branch, I can't quite get it to start, defineConfig got moved? Is there a guide somewhere with the breaking changes?
Sorry I'm a bit confused how defineEventHandler is supposed to be used now? It looks like createStartHandler no longer takes a event: H3Event<EventHandlerRequest>?
Also how do I customize the client.tsx now with custom logic?
import { i18n } from "@lingui/core";
import { hydrateRoot } from "react-dom/client";
import { StartClient } from "@tanstack/react-start";
import { dynamicActivate } from "./modules/lingui/i18n";
import { createRouter } from "./router";
// The lang should be set by the server
dynamicActivate(document.documentElement.lang);
const router = createRouter({ i18n });
hydrateRoot(document, <StartClient router={router} />);
I'm not 100% sure if the approach in Lingui's repo is the best solution to this problem, but basically I'd like to execute some logic on every route in the app, server side, based on the request headers. That might affect how router is rendered and might be async. How do I do that?
setupLocaleFromRequest is defined here. But you might as well simplify it to await Promise.resolve() and remove passing the i18n to createRouter; it's just that I want to be able to await an async function BEFORE createStartHandler.
At the moment it does not work, because of TypeScript error Argument of type 'H3Event<EventHandlerRequest>' is not assignable to parameter of type '{ request: Request; }'. when trying to pass event at the very end; it also doesn't work in runtime.
For essentially the same reason e.g. @clerk/tanstack-react-start does not work in the devinxi/alpha version, at least on 1.121.0-alpha.21. TypeScript won't complain in your official example because you @ts-expect-errored it, but if you try to run pnpm dev on this example: https://github.com/TanStack/router/tree/v1.121.0-alpha.21/examples/react/start-clerk-basic you'll get An error occured while server rendering /index.html: No HTTPEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime..
Reacted by Bo Lingen, Gunnar Torfi Steinarsson, Robert Soriano and Tergel Munkhdelger
Closing this as fixed. If the latest Lingui example still produces duplicated content or head tags because of Start, please open a new issue with the current versions and reproduction.
Activity
schiller-manuel commentedon May 30, 2025
does this still exist on the alpha branch?
longzheng commentedon May 30, 2025
I haven't been following the alpha branch, I can't quite get it to start,
defineConfiggot moved? Is there a guide somewhere with the breaking changes?EDIT: Ah I saw the examples at https://github.com/TanStack/router/tree/alpha/examples/react/start-basic but I'm not seeing a way how to do custom client/server initialization
schiller-manuel commentedon May 30, 2025
checkout #2863 (comment)
longzheng commentedon May 31, 2025
Sorry I'm a bit confused how
defineEventHandleris supposed to be used now? It looks likecreateStartHandlerno longer takes aevent: H3Event<EventHandlerRequest>?Also how do I customize the
client.tsxnow with custom logic?schiller-manuel commentedon May 31, 2025
have a look at our e2e example on how server and client can be customized
https://github.com/TanStack/router/tree/alpha/e2e%2Freact-start%2Fbasic%2Fsrc
paolostyle commentedon May 31, 2025
That link doesn't help at all,
server.tsis just the default mentioned in the docs.The docs here (I found it on X): https://tanstack-com.vercel.app/start/latest/docs/framework/react/server-routes#handling-server-route-requests mention a
defineHandlerfunction which doesn't exist and like @longzheng mentioned,createStartHandlerno longer accepts an event fromdefineEventHandler.I'm not 100% sure if the approach in Lingui's repo is the best solution to this problem, but basically I'd like to execute some logic on every route in the app, server side, based on the request headers. That might affect how router is rendered and might be async. How do I do that?
schiller-manuel commentedon May 31, 2025
@paolostyle what exactly do you need to execute here? is this inside of react?
paolostyle commentedon May 31, 2025
For now I'd like to just make the code posted in OP's last comment work:
setupLocaleFromRequestis defined here. But you might as well simplify it toawait Promise.resolve()and remove passing thei18ntocreateRouter; it's just that I want to be able to await an async function BEFOREcreateStartHandler.At the moment it does not work, because of TypeScript error
Argument of type 'H3Event<EventHandlerRequest>' is not assignable to parameter of type '{ request: Request; }'.when trying to passeventat the very end; it also doesn't work in runtime.For essentially the same reason e.g.
@clerk/tanstack-react-startdoes not work in the devinxi/alpha version, at least on 1.121.0-alpha.21. TypeScript won't complain in your official example because you@ts-expect-errored it, but if you try to runpnpm devon this example: https://github.com/TanStack/router/tree/v1.121.0-alpha.21/examples/react/start-clerk-basic you'll getAn error occured while server rendering /index.html: No HTTPEvent found in AsyncLocalStorage. Make sure you are using the function within the server runtime..gunnartorfis commentedon Jun 11, 2025
Can confirm that the "No HTTPEvent found in AsyncLocalStorage" error is still present in the latest alpha (1.121.0-alpha.27).
smoothdvd commentedon Jun 12, 2025
@longzheng @paolostyle My working code with latest Tanstack Start 1.121.x:
mtergel commentedon Jun 15, 2025
getting duplicate render on prod
depsimon commentedon Jun 18, 2025
I updated the lingui example here, let me know if you still have issues with the new template.
SutuSebastian commentedon Oct 17, 2025
@depsimon it needs yet another update, the v1 RC version changed again API's, contracts, etc
LadyBluenotes commentedon Jul 13, 2026
Closing this as fixed. If the latest Lingui example still produces duplicated content or head tags because of Start, please open a new issue with the current versions and reproduction.