Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parcel-react-ssr

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parcel-react-ssr

Example of SSR with React and ParcelJS

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

parcel-react-ssr

Simple example of how to do server-rendering. You will not believe how easy it is!

Using:

  • parcel-bundler
  • react
  • react-router-dom
  • react-helmet (SEO)

How to run

  • npm run dev - Run the development server with hot reload but no server-rendering
  • npm run build - Build for production, required before running
  • npm start - Start the production server

How does it work?

To do proper server-rendering, the code is bundled in two version: one for the browser and one for Node.js.

The browser version is in the dist/client folder and the Node.js version is in dist/server. However, they both share the same public path for their files: /dist and it points to the browser version. Go read the code, it's pretty straightforward!

Read the code!

  1. package.json - Start by reading the scripts section to understand how the build process works. Yes it's that dead simple!
  2. app/index.html - Your only HTML file acting as a template
  3. app/App.jsx - Your main application component shared between your browser and Node.js version
  4. app/HelloWorld.jsx - Dead simple hello world
  5. app/HelloWorld.scss - Example of SCSS
  6. server/index.js - Entry point for your Node.js version
  7. server/middleware.js - Middleware taking care of server-rendering
  8. server/generateHtml.js - Generate the HTML using index.html as the template with cheerio

Keywords

FAQs

Package last updated on 19 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc