airbnb /hypernova
A service for server-side rendering your JavaScript views
★ 5,776⑂ 216👁 5⑃ 125● 75▤ 0
+0
日增长
5,776
stars
216
forks
5
watchers
125
prs
75
issues
0
releases
README
| :exclamation: Deprecation Notice |
|:-|
|We want to express our sincere gratitude for your support and contributions to the Hypernova open source project. As we are no longer using this technology internally, we have come to the decision to archive the Hypernova repositories. While we won't be providing further updates or support, the existing code and resources will remain accessible for your reference. We encourage anyone interested to fork the repository and continue the project's legacy independently. Thank you for being a part of this journey and for your patience and understanding.|
---
Hypernova
A service for server-side rendering your JavaScript views
Why?
First and foremost, server-side rendering is a better user experience compared to just client-side rendering. The user gets the content faster, the webpage is more accessible when JS fails or is disabled, and search engines have an easier time indexing it.
Secondly, it provides a better developer experience. Writing the same markup twice both on the server in your preferred templating library and in JavaScript can be tedious and hard to maintain. Hypernova lets you write all of your view code in a single place without having to sacrifice the user’s experience.
How?
!Diagram that visually explains how hypernova works
1. A user requests a page on your server.
1. Your server then gathers all the data it needs to render the page.
1. Your server uses a Hypernova client to submit an HTTP request to a Hypernova server.
1. Hypernova server computes all the views into an HTML string and sends them back to the client.
1. Your server then sends down the markup plus the JavaScript to the browser.
1. On the browser, JavaScript is used to progressively enhance the application and make it dynamic.
Terminology
hypernova/server - Service that accepts data via HTTP request and responds with HTML.
hypernova - The universal component that takes care of turning your view into the HTML structure it needs to server-render. On the browser it bootstraps the server-rendered markup and runs it.
hypernova-${client} - This can be something like hypernova-ruby or hypernova-node. It is the client which gives your application the superpower of querying Hypernova and understanding how to fallback to client-rendering in case there is a failure.
Get Started
First you’ll need to install a few packages: the server, the browser component, and the client. For development purposes it is recommended to install either alongside the code you wish to server-render or in the same application.
From here on out we’ll assume you’re using hypernova-ruby and React with hypernova-react.
Node
sh
npm install hypernova --save
This package contains both the server and the client.
Next, lets configure the development server. To keep things simple we can put the configuration in your root folder, it can be named something like hypernova.js.
js
var hypernova = require('hypernova/server');
hypernova({
devTop issues
#48Why is React hydration data within a script tag, commented out?15 comments · 2017-02-14#89Response streaming9 comments · 2017-09-05#22`createGetComponent` doesn't prevent leaking data between requests9 comments · 2016-06-28#165Encode closing Tag8 comments · 2019-10-09#145Proper source map support for development mode8 comments · 2018-11-15#111Guidance needed - how to store request context?5 comments · 2018-03-14#97Open to adding the ability to restart workers 5 comments · 2017-11-06#134TypeError: Promise.promisifyAll is not a function4 comments · 2018-08-03