Skip to content

Typescript React Boilerplate Demo, Currently In Beta🎯.

Notifications You must be signed in to change notification settings

AlaguSelvan/typescript-react-ssr

Repository files navigation

TypeScript React SSR Boilerplate

Who this BoilerPlate for?

This Boilerplate is built for people who have trouble worrying about SEO or configuring SSR from scratch, This Boilerplate solves all the issues with that and It is built to be very much similar to Create-React-App for picking up and working very faster.

Requirements

Getting Started

1. You can start by cloning the repository on your local machine by running:

git clone https://github.com/AlaguSelvan/typescript-react-ssr.git
cd typescript-react-ssr

2. Install all of the dependencies:

yarn

3. Start to run it:

yarn start or npm start # Running Client side with Dev or Prod Config.
yarn build or npm run build # Building bundle

The app Will Run at http://localhost:3000

Note: You can change the port that you want from .env.

Script Commands

yarn <script> Description
start Runs your client at localhost:3000.
build Build your production ready app.
build:client Build your client Files.
compile:client Transpile your client Files present in ./App folder.
build:server Build your server Files.
compile:server Transpile your server Files present in ./server folder.
format format with prettier.
clean Delete all your build folders.
lint lint your client and server Files.

App Structure

Here is the structure of the app, which serves as generally accepted guidelines and patterns for building scalable apps.

.
β”œβ”€β”€ public                          # Express server static path/Webpack bundled output
β”‚   └── favicon.ico                 # Favicon is placed in the same path with the main HTML page
β”‚   └── index.html                  # HTML File for serving Content to the Web.
β”‚   └── logo192.png                 # logo file.
β”‚   └── manifest.json               # Manifest file for PWA.
β”œβ”€β”€ server                          # Server Side Code for serving React SSR.
β”‚   β”œβ”€β”€ utils                       # App configuration settings
β”‚   β”‚   └── HtmlTemplate.ts         # JSX Rendered to static HTML.
β”‚   β”œβ”€β”€ index.ts                    # Default Express Server for serving React app on Port 3000.
β”‚   └── render.tsx                  # Server Side Rendering Logic Goes here
β”œβ”€β”€ app                             # Client Side Code for React.
β”‚   β”œβ”€β”€ container                   # Page components
β”‚   β”œβ”€β”€ components                  # Isolated Components Should go Here(e.g. Button, Switch etc.)
β”‚   β”œβ”€β”€ context                     # For using React Context API
β”‚   β”œβ”€β”€ redux                       # For using Redux for Store
β”‚   β”œβ”€β”€ Router                      # App-wide utils (e.g. configure Redux store, HTML template etc.)
β”‚   β”œβ”€β”€ App                         # Static assets (e.g. images, fonts etc.)
β”‚   └── index                       # App-wide style and vendor CSS framework
β”œβ”€β”€ build                           # All Client and Server side React Code are compiled for Production.
β”‚   β”œβ”€β”€ app                         # All Client side code compiled for Production.
β”‚   β”œβ”€β”€ client                      # Client side Bundle to be served for Production.
β”‚   └── server                      # All Server side code for serving production build
β”œβ”€β”€ tools                           # Project related configurations (testing/build etc.)
β”‚   └── webpack                     # Webpack settings
β”‚       β”œβ”€β”€ client                  # Webpack configuration For Client side Dev and Prod Mode
β”‚       └── server                  # Webpack configuration For Server Config Dev and Prod Mode
β”œβ”€β”€ index.ts                        # App entry point
└── huskyrc                         # Git Pre Commit Hooks

Important Information

This Boilerplate is still in Beta, It will work fine on Development and Production, but still some minor updates and fixes are there which will be fixed soon and This Boilerplate will be ready for everyone.