See Live Demo of this Template
This template includes all the dependencies and set up needed for you to work within defined code standards and structure to get you up and running quickly.
- Clone your new repo to your local machine
- Go to the NEXT section
- Open the
package.json
file and change thename
property to the name of your application, andauthor
to your name - Open the
/public/index.html
file and change thetitle
attribute to the name of your application - Rename the
.env.local.sample
file to.env.local
file. The final file name should be.env.local
- From your command line, be in the root directory and run
npm install
ORnpm i
for short - From your command line, be in the root directory and run
npx husky install
- To start your application, run
npm start
NOTES:
- Changes you make to the project will make the browser reload on save...no more hard refresh unless something goes wrong.
From this time forward, you will be expected to have a clean console in order for your assignments to be approved. Use React Developer Tools Chrome Extension to help with debugging.
If you have a folder of local images that you want to load into your code things get a little strange with webpack. Remember the only way webpack knows about assets is if they are imported into your javascript files. Even our CSS is not added until those files are imported into our javascript files. Below is some sample code for how to load a local image file into your project
import cat from './assets/cat.jpg';
<>
<img src=${cat} alt="picture of a cat"/>
</>
For every file you will need to make an API request in, you will need to import Axios
import axios from 'axios';
const examplePromise = () => {
axios.get('http://localhost:3001/example')
.then((data) => {
console.warn(data);
})
.catch((error) => {
console.error(error);
});
});
- Build Command:
yarn build
- Publish directory:
build
- Add Environmental Variables (NOT REQUIRED for Apps that do not use API Keys, etc)
- Any Enviromental variables you are using in your
.env.local
file should be added to Netlify.- Go to Site settings > Build & deploy > Environment > Environment variables and the keys and values there.
- Any Enviromental variables you are using in your
- Update Firebase URL Settings
- In Firebase under Authentication select sign in methods, scroll to Authorized domains. Add your Netlify URL.
If you are interested in setting up your own project for things outside of class, you can run the command to start a React project npx create-react-app {APP_NAME}
and setup all the files and structures from scratch.