All Projects → kevinschaich → react-full-stack-starter

kevinschaich / react-full-stack-starter

Licence: MIT License
🎈Full-stack React boilerplate using `create-react-app`, Babel, Node.js, and express

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to react-full-stack-starter

node-express-mongo-passport-jwt-typescript
A Node.js back end web application with REST API, user JWT authentication and MongoDB data storage using TypeScript
Stars: ✭ 51 (+131.82%)
Mutual labels:  mongo, mongoose, expressjs, node-js
Mevn Boilerplate
A fullstack boilerplate with Mongo, ExpressJS, VueJS and NodeJS.
Stars: ✭ 277 (+1159.09%)
Mutual labels:  mongoose, expressjs, full-stack, fullstack
mean-stack
MEAN stack Mongoose, Express, Angular6, Node
Stars: ✭ 22 (+0%)
Mutual labels:  mongoose, expressjs, fullstack, fullstack-javascript
timeoff-server
TimeOff is an application that allows companies' employees to set vacations before they begin taking their time off. Implemented in modern tech stack i.e. Node, Express, MongoDB.
Stars: ✭ 33 (+50%)
Mutual labels:  mongoose, expressjs, node-js
Mean Stack Angular6 Crud Example
MEAN Stack Angular 6 CRUD Web Application
Stars: ✭ 69 (+213.64%)
Mutual labels:  mongo, mongoose, expressjs
Node Typescript Mongodb
node js typescript mongodb express generator yo
Stars: ✭ 96 (+336.36%)
Mutual labels:  mongo, mongoose, node-js
mern-stack-crud
MERN stack (MongoDB, Express, React and Node.js) create read update and delete (CRUD) web application example
Stars: ✭ 142 (+545.45%)
Mutual labels:  mongo, mongoose, expressjs
Registration-and-Login-using-MERN-stack
Simple Registration and Login component with MERN stack
Stars: ✭ 210 (+854.55%)
Mutual labels:  mongo, mongoose, node-js
express-mvc-generator
Express' Model View Controller Application Generator.
Stars: ✭ 46 (+109.09%)
Mutual labels:  mongoose, expressjs, node-js
ng-nest-cnode
Angular 10 Front-End and Nestjs 7 framework Back-End build Fullstack CNode
Stars: ✭ 17 (-22.73%)
Mutual labels:  mongoose, expressjs, fullstack
express-boilerplate
ExpressJS boilerplate with Socket.IO, Mongoose for scalable projects.
Stars: ✭ 83 (+277.27%)
Mutual labels:  mongoose, expressjs, node-js
NodeRestApi
Node.js, Express.js and MongoDB REST API App
Stars: ✭ 38 (+72.73%)
Mutual labels:  mongo, mongoose, expressjs
Mean Angular4 Chat App
MEAN stack with Angular 4 Chat App
Stars: ✭ 41 (+86.36%)
Mutual labels:  mongo, mongoose, expressjs
Node Production
Take Your Node.js Project to The Production Environment (VPS/Dedicated Server).
Stars: ✭ 35 (+59.09%)
Mutual labels:  mongo, expressjs, node-js
Mevn Stack
A Quickstart for building an Express API with a VueJS Admin Portal
Stars: ✭ 178 (+709.09%)
Mutual labels:  mongo, expressjs, full-stack
Vue Express Mongo Boilerplate
⭐ MEVN Full stack JS web app boilerplate with NodeJS, Express, Mongo and VueJS
Stars: ✭ 2,814 (+12690.91%)
Mutual labels:  mongo, fullstack, fullstack-boilerplate
express-mongo-jwt-boilerplate
Express Mongo JsonWebToken boilerplate
Stars: ✭ 100 (+354.55%)
Mutual labels:  mongo, mongoose, expressjs
passport-examples
A variety of examples using PassportJS with ExpressJS and ReactJS applications
Stars: ✭ 44 (+100%)
Mutual labels:  create-react-app, mongoose, expressjs
React Express Fullstack
Full stack (mostly unopinionated) starter pack with React+Redux and Expressjs
Stars: ✭ 23 (+4.55%)
Mutual labels:  babel, full-stack, fullstack
mern-stack-application
A MERN stack e-commerce website.
Stars: ✭ 45 (+104.55%)
Mutual labels:  mongoose, expressjs, fullstack-javascript

React Full-Stack Starter Kit

Full-stack React boilerplate using create-react-app, Babel, Node.js, and express. Plays nicely with DB connectors such as MongoDB, Mongoose, MySQL and many others.

Fully-updated for ES6 syntax.

Loosely Based on Fullstack React's demo, just leaned-out. Check out their blog post for details on how the proxy setup allows a concurrent client/server side.

Installation/Usage

Run the following in your terminal:

git clone https://github.com/kevinschaich/react-full-stack-starter
cd react-full-stack-starter
npm install

cd client
npm install

cd ..
npm start

Visit http://localhost:3000 in your browser to see the server running!

Note for Windows Users: If you encounter errors during installation, I recommend giving CMDer a try.

Example DB Connection with MongoDB

Install MongoDB

Make sure you have MongoDB installed. If you don't have any databases set up, you can run this command to populate a few rows (be sure to change db-name and collection-name):

mongo db-name --eval 'db.collection-name.insert({"name": "John Doe"}, {"name": "Jane Doe"})'

Run the following in the root directory of the repository:

npm install --save mongodb

Configure MongoDB

In the top of server.js, add the following lines to import Mongo and set the database URI. Be sure to replace database-name-here with the name of your database in Mongo.

const MongoClient = require('mongodb').MongoClient;
const url = 'mongodb://localhost:27017/database-name-here';

Retrieve objects from DB

Now, near the bottom of server.js, update the app.get('/api'...) route to retrieve data from your DB. Be sure to replace collection-name-here with the name of your collection in Mongo.

app.get('/api', (req, res) => {
  MongoClient.connect(url).then(db => {
    const cursor = db.collection('collection-name-here')
      .find({})
      .limit(5)
      .toArray()
    .then((data) => {
      res.json(data);
    });
  }).catch(err => {
    console.log(err);
  });
});

Your server should be pulling items from the database when it receives a call to /api. You can test this by visiting http://localhost:3001/api and see if the response is displayed properly.

Update Client Code

Back on the client side, in client/src/App.js, you need to update your render method to match the format of objects in MongoDB. For example, if your stored objects in Mongo look like the following:

[
  {"name": "Person1", "age": 38},
  {"name": "Person2", "age": 27},
]

You could change the mapping to populate the name field of each item on the page like so:

  const items = this.state.items.map(
    (item, i) => (<h1 key={i}>{item.name}</h1>)
  );

Run the server using npm start -- you should see items from your DB being populated on the page!

Deploying to Heroku

Install the Heroku CLI and set up your account if you haven't already.
Follow the instructions here.

Run the following in your terminal

# cd into client folder and run the build script
cd client
npm run build
cd ..

# commit the changes to git
git add .
git commit -m "build for deployment"

# create the heroku app and deploy
heroku create
git push heroku master

Contributing/Pull Requests

Please feel free to submit issues/pull requests! I welcome any corrections or suggestions that could make the repository better for others to use and build off of as well.

License

MIT © Kevin Schaich

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].