3 ms·
Is there any SSR web framework besides NextJS that lets me use JSX?
by mattgreenrocks 2y ago
Is there any SSR web framework besides NextJS that lets me use JSX?
- tharmas 2y agoYes, would like to know too. I know that the latest version of React features more SSR capabilities of components without (I think, but don't know for sure) the requirement of NextJS.
- throwitaway1123 2y agoReact has always had the ability to do SSR without Next. You can call renderToString on the server to generate html strings, and then hydrateRoot on the client to pick up where the server left off.
- tharmas 2y agoThank you.
- throwitaway1123 2y agoIf you like JSX as a templating language and you want to generate simple html strings then just use vhtml with TypeScript [1][2]. You have to import the h function from vhtml in your tsx files, and then update your tsconfig file so that TypeScript knows what to transform the JSX into: "jsx": "react", "jsxFactory": "h", "jsxFragmentFactory": "null", If you want something a little more powerful then hono/jsx is a decent choice [3]. [1] https://github.com/developit/vhtml https://github.com/developit/vhtml [2] https://github.com/developit/vhtml/issues/31 https://github.com/developit/vhtml/issues/31 [3] https://hono.dev/docs/guides/jsx https://hono.dev/docs/guides/jsx
- dsego 2y agoBun and Deno support .jsx and .tsx files out of the box. https://bun.sh/docs/runtime/jsx https://bun.sh/docs/runtime/jsx https://docs.deno.com/runtime/manual/advanced/jsx_dom/jsx/ https://docs.deno.com/runtime/manual/advanced/jsx_dom/jsx/ You have to sub the JSX factory, eg React.createElement with a library that spits out html instead of building a DOM tree. It's not hard to do, for example I created this tiny library to play around with async server-side components. https://github.com/dsego/ssr_jsx https://github.com/dsego/ssr_jsx I think for Deno you have their Fresh framework which does JSX components https://fresh.deno.dev/ https://fresh.deno.dev/.