Skip to content

Instantly share code, notes, and snippets.

@jeanlescure
Created April 29, 2020 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanlescure/803d21ebae79b97737895d663ffd2d1f to your computer and use it in GitHub Desktop.
Save jeanlescure/803d21ebae79b97737895d663ffd2d1f to your computer and use it in GitHub Desktop.
React.js quick dev server on Deno minimal example
import React from 'https://dev.jspm.io/react';
export const App = () => {
return (
<div>Hello React.js quick dev server with Deno example!</div>
);
};
import { serve } from 'https://deno.land/std/http/server.ts';
import React from 'https://dev.jspm.io/react';
import ReactDOMServer from 'https://dev.jspm.io/react-dom/server';
import { App } from './app.tsx';
export const str = ReactDOMServer.renderToString(<App />);
const body = new TextEncoder().encode(str);
const server = serve(':8080');
// To start this server simply run: deno ./server.tsx
window.onload = async () => {
console.log('Server started at: http://localhost:8080/');
for await (const req of server) {
req.respond({ body });
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment