Giter Site home page Giter Site logo

cyyynthia / react-hybrid-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
4.0 0.0 0.0 492 KB

A boilerplate to quickly start working on React projects using hybrid rendering

License: BSD 3-Clause "New" or "Revised" License

JavaScript 90.54% CSS 9.46%
react frontend boilerplate react-ssr template-project webdev pnpm

react-hybrid-boilerplate's Introduction

React Hybrid Boilerplate

ko-fi
License Discord

A boilerplate to quickly start working on React projects using hybrid rendering.

Hybrid rendering?

Basically, in production there is a small web server (here pure native http module) that'll be in charge of pre-rendering your React application. It then gets hydrated client-side, which means React will then bind all the events it needs to bind and work as if it was CSR. It helps to enhance SEO, load times, and makes your application usable by users who disabled JavaScript.

Features

  • No expressjs: It uses Node's http module to create the web server, and not bloated stuff;
  • Hot reload: It is capable of hot reloading while developing;
  • react-helmet and react-router are ready to be used, no extra-setup required;
  • Image minification with imagemin in production builds;

There are also some env variables that get injected in your application through webpack's DefinePlugin:

  • WEBPACK.GIT_REVISION - Git revision; null if git isn't present.

You're of course able to edit the configuration to your needs.

Note: This boilerplate uses css modules by default. You can disable them by looking at webpack.config.js line 90.

How to use

Aliases

  • @components/*: src/components/*
  • @styles/*: src/styles/*
  • @assets/*: src/assets/*

How to run

Note: This boilerplate uses pnpm for dependency management.

Development

Both webpack and the http server must be running

  • pnpm run dev - Runs the http server with nodemon
  • pnpm run watch - Runs webpack dev server

Then, open http://localhost:8080 in your web browser and start tinkering!

Production

  • Build the app: pnpm run build
  • And then start the http server! pnpm run start

You can change the port by setting the PORT env variable. By default, it'll listen on http://localhost:6969.

Things I consider adding in the future

  • TypeScript support
  • Redux support
  • Something to easily configure the boilerplate w/o having to edit stuff (cli args? env vars? install script?)
  • Markdown support (Export as React component)

react-hybrid-boilerplate's People

Contributors

cyyynthia avatar

Stargazers

 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.