百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

TypeScript-MERN-Starter

> 前端框架
开源

在 100% TypeScript 中构建真正的全栈应用程序(后端+网站+移动端)

390 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

在 100% TypeScript 中构建真正的全栈应用程序(后端+网站+移动端)

TypeScript MERN Starter

Live Demo: https://hd283.net/

Supported Clients Preview
Web
Web (Mobile)
Android
iOS

This project built a real blog app for all platforms in TypeScript.

TypeScript is a typed super set of JavaScript. If you are new to TypeScript it is highly recommended to become familiar with it first before proceeding. You can check out its documentation here.

MERN stands for MongoDB, Express.js, React/ReactNative, and Node.js.

TypeScript has brought the following benefits to MERN:

  • Unified modeling across web client and server for objects
  • Type safety, and easy refactoring of typed code across web client and server
  • A superior developer experience in a team environment

Not only using TypeScript, but this project is also featured by:

  • Real fullstack, because you can build node server, Mongo DB, multimedia storage, website (for both desktop and mobile), Android app, and iOS app based on this project in single programming language.
  • RESTful-style. Powered by an embedded oauth2 server and passport.js, this project separate client and server clearly. Then the REST server can serve for both website and mobile clients simultaneously.
  • React-router 4.0+, with it you can easily define client routes and manage them.
  • Redux, with it you can easily manage client states. Also all clients shared the same state machine implemented by Redux, we reduced a lot of effort when you develop for multi-clients.
  • Almost ready for a blog app. We modeled User as well as Article. This is a real starter for who would like to build a blog app or extend it to a community app using MERN.
  • The web client code is created from create-react-app, so now you can get rid of annoying configurations for babel and webpack.
  • The Android/iOS client is created from Expo, which is a tool encapsulated a lot of complexity when you develop on ReactNative.

Table of Content

  • Quick start
    • Before Start
    • Clone the repository
    • Install dependencies
    • Start your mongoDB server
    • Build and run the project
    • Start the mobile apps
  • Motivation
    • Prior Art
    • Philosophy
    • Work Items
  • Project structure
    • Dependencies
    • Folder structure
    • Create React App
      • Serve static assets of client and index.html in production
      • Proxy API requests in development
    • Unified Modeling
    • Embedded OAuth2 server
      • OAuth 2.0 protocol
      • Resource server
      • Authorization server
      • Summary of OAuth2 server
    • Server routing & client routing
      • React-router 4.0+
      • Performance perspective
    • Styling
  • How to debug
    • Available scripts
    • Debugging website client
    • Debugging mobile client
    • Debugging server
    • Debugging tests
  • Tests
  • Deploying the app
    • Prerequisite
    • Create production MongoDB (Option 1: Azure CosmosDB)
      • Open Azure Cloud Shell
      • Create a resource group
      • Create a Cosmos DB account
      • Retrieve the database key
      • Configure the connection string in your Node.js application
    • Create production MongoDB (Option 2: MongoDB Atlas)
    • Create a production blob storage
    • Test the application in production mode
    • Build app into a Docker image
      • Configure environment variables for production
      • Build app into a local Docker image
      • Push Docker image to Docker hub
    • Create an Azure app service using Docker image
      • Add an Azure app service in Azure portal
      • Verify your Azure app service
    • Map custom domain and bind SSL certificate
    • Deploy the mobile apps
    • Summary of deployment

Quick start

Before Start

To build and run this app locally you will need a few things:

  • Install Chrome
  • Install Node.js
  • Install MongoDB
  • Install VS Code
  • Install Yarn
  • Install Expo Cli

Clone the repository

bash
git clone https://github.com/shanhuiyang/TypeScript-MERN-Starter.git 

Install dependencies

bash
cd 
yarn

Start your mongoDB server

(you'll probably have to start another command prompt)

bash
mongod

Note! While you just installed MongoDB (for both on OSX or Windows), it may remind you that you can run MongoDB as service, then your MongoDB will always be running even after you restart your computer.

Build and run the project

bash
yarn start

Finally, navigate to http://localhost:3000 and you should see the blog page being served and rendered locally!

Note! You cannot open the localhost website on IE and Edge browser. In contrast, you can open it on Safari, Firefox, and Chrome. However, we will ensure the compatibility of the production app on IE and Edge browser.

Start the mobile apps

The command yarn start will also start the react-native project using expo-cli. So you can navigate to http://localhost:19002 and you will see the Expo DevTool page. From that page you can easily start your app for both Android and iOS by clicking corresponding buttons.

For more detail of prerequisite please refer to Installation of Expo document.

Briefly speaking, you should prepare for devices you would like to debug on, either emulator/simulator or physical devices.

[TODO] Elaborate this part.

Note! Currently you cannot test Android app on emulator without configure the host url manually. This is because in Android emulator you cannot access http://localhost which hosted on the same server/PC/Mac. You can test your app in the same LAN, see next section for detail.

Optional: Test your app on other device in the same LAN

By default the request url connect client and service are http://localhost, i.e. you can only test client and service in the same server/PC/Mac.

To test your app in LAN, you can do following before enter command yarn start.

  1. Get the IP address (either global IP or LAN IP) of your development server.
  2. Modify the constant HOST_NAME_DEV in client/core/src/models/HostUrl.ts with the IP address you got.

Optional: Test with OTP sending

This project implement the auth service, as well as account verification by sending OTP to user's registered email account.

By default the account verification is turned off since SMTP transporter is not configured with account and password.

To test this part of functionality, you can:

  1. add your email account and password to server/config/smtp-transporter.ts.
  2. change the flag to true in client/core/src/shared/constants.ts.

Motivation

Up to 2020, React is the most popular front-end framework. For novice web developers, if they would like to build a full-stack project using Javascript, they can intuitively choose the combination of Node.js and React.

Typescript is a success Javascript alternative which can keep the maintainability as the project grows. The most famous Typescript project is Angular. Nowadays React also support Typescript officially.

Therefore, the motivation of this project is building a fullstack web app using Typescript, then we can maintain and extend a web app easily.

On the other hand, we have seen the template like TypeScript-Node-Starter, TypeScript-React-Starter, and TypeScript-React-Native-Starter. What if we mixed these 3 projects together? How could Typescript shows its advantage if we use it across client & server? So this project is intended to explore the capability of Typescript in that circumstance.

Prior Art

mern-starter is a famous project which combine React and Node.js in a single project. However, it is deprecated after April, 2019. This project is a server rendering solution. It modeled the Post object, but did not implement the authentication module.

TypeScript-Node-Starter is an officially built starter project for Node.js by Microsoft. This project is a good starter for Node.js app using Typescript. It is also a server rendering solution, using pug.

Indeed TypeScript-MERN-Starter is built on top of TypeScript-Node-Starter. However, as you can see in TypeScript-MERN-Starter, the architecture has been totally changed comparing to TypeScript-Node-Starter.

oauth2api is a good example on how to implement OAuth2 strategy in an Node.js app. We almost totally imported this project to TypeScript-MERN-Starter.

Philosophy

We build this project on following philosophies:

  1. Beginner friendly. You can start the app without any complex configuration for build and runtime.
  2. Easy to extend. You can always focus on your business logic. We chose well-documented 3rd party packages to use, so that you can extend this app easily by following the working patterns of these packages.
  3. Share the code as much as possible. For example, usually we prefer the 3rd party package who can be used both in React and ReactNative, such as ReactRouter, ReactIntl, etc. In contrast, we gave up to use ReactNavigation, expo-localization which can only used in ReactNative.

Work items

We have already extended this project from MERN to MERRN, where the additional R stands for ReactNative.

In next period of time (Before end of Fe

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptandroidexpoexpressfullstack

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架