Public
Like
2
custom-jsx-runtime-starter
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
http.tsx
https://jxnblk--d561862221d011f0a559569c3dd06744.web.val.run
This starter demonstrates how to use a custom JSX runtime in Val Town.
The http.tsx
file is the main entry point and renders an HTML response on the server using React.
This HTML includes a <script>
tag to load the client.tsx
file, which hydrates the React app.
The JSX pragma at the top of files is:
/** @jsxImportSource ./jsx */
This points to the jsx/jsx-runtime
module (the jsx-runtime
name is important),
which wraps the default React JSX runtime with a function that extracts an sx
prop and applies it as the style
prop.
When the client module requests the App.tsx
file from Val Town, the JSX is compiled to vanilla JavaScript to run in the browser.