All Projects → styfle → React Server Example Tsx

styfle / React Server Example Tsx

Licence: mit
⚛️ Boilerplate for isomorphic web app with React server-side rendering in TypeScript

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Server Example Tsx

Universal React Demo
ES6 demo of a simple but scalable React app with react-router, code splitting, server side rendering, and tree shaking.
Stars: ✭ 50 (-80.47%)
Mutual labels:  isomorphic, jsx, server-side-rendering
React App
Create React App with server-side code support
Stars: ✭ 614 (+139.84%)
Mutual labels:  isomorphic, boilerplate, server-side-rendering
Razzle Material Ui Styled Example
Razzle Material-UI example with Styled Components using Express with compression
Stars: ✭ 117 (-54.3%)
Mutual labels:  isomorphic, boilerplate, server-side-rendering
React Isomorphic Boilerplate
🌟 An universal React isomorphic boilerplate for building server-side render web app.
Stars: ✭ 653 (+155.08%)
Mutual labels:  isomorphic, boilerplate, server-side-rendering
Project Webcube
Continuously updated JS infrastructure for modern web dev
Stars: ✭ 141 (-44.92%)
Mutual labels:  isomorphic, boilerplate, server-side-rendering
Nano
🎯 SSR first, lightweight 1kB JSX library.
Stars: ✭ 238 (-7.03%)
Mutual labels:  isomorphic, jsx
core
Server side rendering with The Elm Architecture in Deno
Stars: ✭ 16 (-93.75%)
Mutual labels:  jsx, server-side-rendering
universal-react-relay-starter-kit
A starter kit for React in combination with Relay including a GraphQL server, server side rendering, code splitting, i18n, SEO.
Stars: ✭ 14 (-94.53%)
Mutual labels:  isomorphic, server-side-rendering
docker-bare-infra
Docker based, minimal infrastructure boilerplate, with MySQL, WordPress, a React application and Nginx
Stars: ✭ 11 (-95.7%)
Mutual labels:  isomorphic, server-side-rendering
Use Ssr
☯️ React hook to determine if you are on the server, browser, or react native
Stars: ✭ 230 (-10.16%)
Mutual labels:  isomorphic, server-side-rendering
boldr
React based CMF / blogging engine using Redux, Postgres, Node, and more...
Stars: ✭ 78 (-69.53%)
Mutual labels:  isomorphic, server-side-rendering
fastify-vite
This plugin lets you load a Vite client application and set it up for Server-Side Rendering (SSR) with Fastify.
Stars: ✭ 497 (+94.14%)
Mutual labels:  isomorphic, server-side-rendering
Beidou
🌌 Isomorphic framework for server-rendered React apps
Stars: ✭ 2,726 (+964.84%)
Mutual labels:  isomorphic, server-side-rendering
Arc
React starter kit based on Atomic Design
Stars: ✭ 2,780 (+985.94%)
Mutual labels:  isomorphic, boilerplate
ves
Vue SSR(Server Side Render) Web Framework for Egg
Stars: ✭ 23 (-91.02%)
Mutual labels:  isomorphic, server-side-rendering
Universal React
A universal react starter, with routing, meta, title, and data features
Stars: ✭ 247 (-3.52%)
Mutual labels:  isomorphic, server-side-rendering
webpack-isomorphic
A lightweight solution for the server-side rendering of Webpack-built applications.
Stars: ✭ 21 (-91.8%)
Mutual labels:  isomorphic, server-side-rendering
kaonjs
Kaon.js is a react isomorphic app solution. It contains webpack build, hot reloading, code splitting and server side rendering.
Stars: ✭ 21 (-91.8%)
Mutual labels:  isomorphic, server-side-rendering
react-ssr-starter
🔥 ⚛️ A React boilerplate for a universal web app with a highly scalable, offline-first foundation and our focus on performance and best practices.
Stars: ✭ 40 (-84.37%)
Mutual labels:  isomorphic, server-side-rendering
alef-component
Alef Component for Modern Web Apps.
Stars: ✭ 46 (-82.03%)
Mutual labels:  jsx, server-side-rendering

react-server-example-tsx

npm Downloads Dependency Status devDependency Status LGTM Quality Build Status

A complex example of how to do server-side rendering with React and TypeScript so that component code can be shared between server and browser (also known as isomorphic javascript).

Server-Side Rendering (SSR) leads to fast initial page loads, search-engine-friendly pages, and of course...its all type safe!

Getting Started

Clone the repo, change directory, install dependencies, build the code, and run it!

git clone https://github.com/styfle/react-server-example-tsx.git
cd react-server-example-tsx
npm install
npm run vercel-build
npm run test
npm start

Then navigate to http://localhost:3007 and click on the buttons to see some reactive events in action.

Preventing XSS

The original code from mhart attempts to sanitize the props by escaping and then inserting into a <script> tag.

I avoided this by performing 1 extra http request to fetch the props as json before initializing React in the browser. This means that click handlers will not be initialized until the data is returned and React can pick up where it left off after the server-side render and attach the click even handlers. This is the purpose of ReactDOM.hydrate.

See browser.tsx for the client-side code.

See server.ts for the server-side code.

Prior art

Based on prior work found at mhart/react-server-example. It's very good so you should check it out :)

Additionally, I use a combination between TypeScript Handbook and awesome-typescript-loader when I switched from browserify v1.4.x to webpack v2.0.x (now webpack v4.x).

Author

Developed by styfle, the author of Package Phobia

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].