React Native template

Introduction

Creating a template for react-native involves creating a repository in a certain format. Once you have this repository you can have it as part of an initialisation command to create a new project. The initialisation command is as below (replace with your git repo address):

npx react-native init MyApp --template https://github.com/codedplanetuk/react-native-typescript-defaults.git

It is important to maintain the template to be up-to-date when new versions of React Native are released.

Repo format

In your project you should have a folder normally called "template". Inside this folder should be a typical React Native project setup to how you want it to be. Also in the root should be a template.config.js file with contents as below:

module.exports = {
  placeholderName: 'HelloWorld',
  templateDir: './template',
}

Resources

The template I have created that is based on an existing Typescript template but has a some extra boilerplate built in. I have added a folder structure based on that used in the react-native-boilerplate.

My React Native Template is available here: https://github.com/codedplanetuk/react-native-typescript-defaults