Open deniznet opened 2 months ago
Hi there!
This issue has been discussed before, for example here: https://github.com/fast-reflexes/better-react-mathjax/issues/33
I would like to get SSR working with Mathjax and better-react-mathjax
but currently, I don't know if it's possible and in what direction such work would take place. I have a playground locally where I'm trying to get this going but I have had very limited success. I think the gist is that Mathjax originally was built as a client-side library typesetting the DOM in the browser and in the backend there is no DOM in the traditional sense. Perhaps it would be nice to render the backend in a virtual backend DOM and typeset with Mathjax and THEN "serialize" it to HTML code and send it to the frontend but I don't know how to do that currently.
The short answer is, SSR is not currently possible and the long answer is "I hope SSR will be possible in the future" :)
I'm ready to put a reasonable amount of work into this so if anyone has a clear idea on how to do this, I'm all ears :)
Just a follow-up, the error you're SEEING might be connected to something else (both esm and cjs modules are exported from this library and maybe the wrong gets imported during SSR somehow but even if that worked, something else would fail because the MathJax script installs itself onto the window
object which doesn't even exist during SSR so I guarantee it wouldn't work.
We could do typesetting manually with Mathjax from the Mathjax package but this process is not at all as simple (we usually just pass DOM nodes to Mathjax and they typeset but as I recall it, it could not be done that easily when you do it manually). Might give this some more time in the near future because I'm eager to solve it.
Thank you for answer!
Hello! I'm tring run ssr in exist project laravel+inertia+react(typescript)+MathJax+MathLive. Run SSR by https://inertiajs.com/server-side-rendering. Run "npm run build" without error, but when I started "php artisan inertia:start-ssr", I get error:
On page with MathJax
When I added code to page as show:
I get error on "npm run build":
Without SSR all work fine. What I should do? How to run MathJax with SSR? Thank you!