TanStackT
TanStackโ€ข14mo agoโ€ข
5 replies
rubber-blue

SSR and (Framer) Motion

Is there any idiomatic way to use Motion (previously Framer Motion) with TanStack Start without getting hit by and SSR error ?

I get this error with react 19

Uncaught Error: Switched to client rendering because the server rendering errored: Export named 'createContext' not found in module '/Users/notkamui/Dev/time-recorder/node_modules/motion/src/react.ts'.

(React 18 only shows the second paragraph)

Motion should be perfectly isomorphic since it works perfectly fine with Nextjs use client components (which are SSRed then hydrated, like with Start)

To be precise, this error is cause by simply using anything imported from "motion" in a component. That means that even using a guard like if (typeof document === 'undefined') return null before using said motion component doesn't solve the issue (is this a codesplitting issue then ?)

Thank you in advance ๐Ÿ˜„
Was this page helpful?