Coder Social home page Coder Social logo

gourmetjs / gourmet-ssr Goto Github PK

View Code? Open in Web Editor NEW
47.0 4.0 2.0 5.05 MB

A React Server-Side Rendering Engine for Production

Home Page: https://ssr.gourmetjs.org

License: MIT License

JavaScript 99.15% CSS 0.85%
ssr react webpack isomorphic server-rendering universal nextjs code-splitting

gourmet-ssr's Introduction

Latest Version Last Commit Open Issues Node Version Requirement Website Status Main Language PRs Welcome License

Introduction

  • Library, not Framework - Gourmet SSR is designed to be used as a view library in your existing project. We worked very hard to make Gourmet SSR unobtrusive.
  • Production First - Small footprint at runtime, chunked transfer, long-term caching, HTTP/2 optimized bundling and much more. Production is always the number one priority of Gourmet SSR.
  • Human Friendly - Developers are humans too. When we a new feature, the first thing we consider is how to make it easy to understand and use - just like we do for the consumer products.
  • Flexible - Gourmet SSR can be deployed as an in-process VM sandbox, a separate process, a remote HTTP cluster or an AWS Lambda function. Your server can be Django or Rails. The view layer is not limited to React.

Quick Overview

You write the user interface without complicated bootstrapping or boilerplate. It is just a plain tree of React components.

// hello.js
import React from "react";

export default function Hello({greeting}) {
  return <div>{greeting}</div>;
}

Configuration is designed to be minimal, but not to the level of "magic". Here, we specify the above React component as a root component of the main page.

// gourmet_config.js
module.exports = {
  pages: {
    main: "./hello.js"
  }
};

Gourmet SSR is just a view library in your server. This is how you render and serve the main page.

// server.js
const express = require("express");
const gourmet = require("@gourmet/client-lib");

const app = express();

app.use(gourmet.middleware());

app.get("/", (req, res) => {
  res.serve("main", {greeting: "Hello, world!"});
});

app.listen(3000, () => {
  console.log("Server is listening on port 3000");
});

The content is rendered on the server-side and rehydrated on the client-side. Required assets are also linked statically.

The HTML output has all the elements it needs to render the initial user interface - which is great for SEO and user experience.

$ curl http://localhost:3000
<!doctype html>
<html lang="en">
  <head>
    <script defer src="/s/vendors~main.js"></script>
    <script defer src="/s/main.js"></script>
  </head>
  <body>
    <div id="__gourmet_content__"><div id="__gourmet_react__"><div>Hello, world!</div></div></div>
    <script>window.__gourmet_data__={"renderedLoadables":[],"clientProps":{"greeting":"Hello, world!"},"reactClientRender":"hydrate"};</script>
  </body>
</html>

Documentation

Learn more about using Gourmet SSR on the official website.

License

Gourmet SSR is open source software licensed as MIT.

gourmet-ssr's People

Contributors

asyncmax avatar jonmarkprice avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.