Last active
August 2, 2016 14:40
-
-
Save DylanPiercey/4eab06ee4b5facbf7ee2 to your computer and use it in GitHub Desktop.
An Isomorphic Rill snippet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creating an app is familiar. | |
const app = require("rill")(); | |
// Lets pull in some middleware! | |
app.use(require("@rill/logger")()); // Setup logging. | |
app.use(require("@rill/react")()); // Setup our react renderer. | |
// Lets make our index page! | |
app.get("/", ({ req, res })=> { | |
// Simply set the response body to a React Element. | |
// This will send html in the server and | |
// update the dom in the browser. | |
res.body = <MyApp title="Rill"/>; | |
}); | |
// Listen will start a node server, or start the event listeners in the browser. | |
app.listen({ port: 3000, ip: "0.0.0.0" }); | |
// Extremely simple full page React Component. | |
function MyApp (props) { | |
// Using JSX | |
return ( | |
<html> | |
<head> | |
<title>My App - Home</title> | |
</head> | |
<body> | |
Welcome to { props.title } life. | |
<a href="/away">Take me away!</a> | |
<script src="/app.js"/> | |
</body> | |
</html> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
Is this code in some repo? I just want to run this locally to play with this, and was wondering about bundling tools.