Giter Site home page Giter Site logo

ryanlamansky / react-redux-typescript-dotnet-core-ssr-hmr Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 6.0 166 KB

React + Redux + TypeScript + .NET Core + Server-Side Rendering (SSR) + Hot Module Replacement (HMR)

License: Apache License 2.0

TypeScript 55.61% CSS 11.03% C# 13.24% JavaScript 15.47% HTML 4.66%
react redux typescript dotnet-core ssr hmr

react-redux-typescript-dotnet-core-ssr-hmr's Introduction

React + Redux + TypeScript + .NET Core + Server-Side Rendering (SSR) + Hot Module Replacement (HMR)

A sample project combining a variety of useful web development technologies originally shown to work together with .NET Core 2.0's dotnet new reactredux, but updated for .NET Core 2.1 and newer versions of various libraries.

Background

When .NET Core 2.0 was released, it included an excellent project template that combined React and Redux for the front end, .NET Core for the web API, with support for both server-side rendering (SSR) and hot module replacement (HMR). It was amazing!

When .NET Core 2.1 was released, this template was replaced by a much more primitive one that lacked SSR and HMR.

About this Project

This repository aims to preserve the useful feature set of the original .NET Core 2.0 template while keeping the client and server-side libraries up to date. It is not in any way endorsed or supported by Microsoft, but it may prove useful to others who want this combination for their own projects.

Besides updating to newer versions of dependencies, it has been modified in the following ways:

  • JQuery and Bootstrap have been replaced by hand-crafted SCSS and JavaScript, reducing bundle size considerably.
  • The separate "vendor" JavaScript bundle has been removed; it had several negative side effects that weren't worth the gains.
  • Code quality has improved through use of newer TypeScript features.
  • Some newer React features have been applied.

If time permits, the project will continue to be updated and improved (I use it for a lot of my own projects!), but there are no specific plans.

Deviance

This project has a few characteristics that some might consider... unnatural.

  • Not many React projects use TypeScript, Facebook strongly prefers the much less popular "Flow" while most general React users seem to go without any compile-time type checking.
  • It's almost unheard of for a React project to be built without Babel, and yet this one does with no functionality loss.
  • Although React has excellent server-side rendering support, I haven't seen many project templates use it, so it's somewhat of a dark art for many people.

IDE Compatibility

Tested on Visual Studio 2017, 2019, and Code. It has no Windows dependencies and is relatively low complexity, so it should work with a variety of IDEs and operating systems.

Structure

  • Solution.sln is the entry point for "classic" editions of Visual Studio (Pro, Community, etc).
  • WebUI/WebUI.csproj is a suitable starting point for Visual Studio Code.
  • WebUI/Startup.cs the entry point for the .NET code.
  • WebUI/ClientApp contains all of the front-end script, including entry points for client and server side.
  • WebUI/Controlers are conventional ASP.NET MVC-style controllers.
  • WebUI/Views are conventional ASP.NET MVC-style views used to set up the general HTML environment for React to use.

Troubleshooting

  • Visual Studio may not restore NPM packages on startup, fix by running npm install manually or by expanding Dependencies and right-clicking "npm" and choosing Restore Packages.

Known Issues

  • This project currently uses the abandoned "react-router-redux" package, which will need to be replaced.

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.