3 ms·
1. People are building actual applications with client side interactivity on the web now. 2. Programmers prefer using programming languages over templating lan
by brigadier132 2y ago
1. People are building actual applications with client side interactivity on the web now.
2. Programmers prefer using programming languages over templating languages. Jsx allows you to mix js with xml and also generally supports better composability than templates (another thing programmers prefer).
3. Some programmers like to use jsx for normal websites with ssr under the spirit of "use what you know".
- mattgreenrocks 2y agoIs 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/.