An open API service indexing awesome lists of open source software.

https://github.com/byntangxyz/fullstack-js-with-auth

React + Express + MongoDB, a javascript fullstack with authentication
https://github.com/byntangxyz/fullstack-js-with-auth

authentication expressjs fullstack javascript mongodb reactjs template

Last synced: 3 months ago
JSON representation

React + Express + MongoDB, a javascript fullstack with authentication

Awesome Lists containing this project

README

          

# MERN Template with Auth

![Preview-1](./preview/home-d.png)

Well you're Javascript ethusiast? You want to build a web application with a backend and a frontend only using javascript? This template may be for you!

I've been creating a template for a web application using Express, ReactJS and MongoDB. This template includes simple authentication system and dashboard with middleware protection. Here's are all the ✨ Features:

- πŸ” Register & Login using JWT
- 🧱 Protected Routes (Dashboard, Settings)
- βš™οΈ Change Password, Logout, and Delete Account
- πŸŒ— Dark Mode Support
- 🎨 Responsive TailwindCSS UI
- πŸ”§ Structured backend (Controller, Middleware, Model)
- πŸ”₯ Integrated directly between frontend and backend

## Folder Structure

```bash

πŸ“¦project-root
β”œβ”€ πŸ“server/
β”‚ β”œβ”€ controllers/
β”‚ β”œβ”€ middleware/
β”‚ β”œβ”€ models/
β”‚ β”œβ”€ routes/
β”‚ β”œβ”€ server.js
β”‚ └─ .env.example
β”œβ”€ πŸ“src/
β”‚ β”œβ”€ pages/
β”‚ β”œβ”€ context/
β”‚ β”œβ”€ layout/
β”‚ └─ main.jsx
β”œβ”€ πŸ“public/
β”œβ”€ package.json
└─ README.md

```

## Installation Guide

### 1. Clone Repository

```bash
git clone https://github.com/byntangxyz/fullstack-js-with-auth.git
cd fullstack-js-with-auth
```

### 2. Install Dependencies

Using npm:

```bash
npm install
```

Using pnpm:

```bash
pnpm install
```

### 3. Setup Environment Variables

```bash
cp server/.env.example server/.env

```

You can modify the `.env` file to suit your needs. Here are the default configuration:
```env
MONGO_URI=mongodb://localhost:27017/yourdb
JWT_SECRET=iloveyoursister
PORT=5000
```
> Make sure you've installed [MongoDB](https://www.mongodb.com/try/download/community) on your computer

### 4. Run the Application

```bash
npm run dev
```

Script Avaliable:

| Script | Commands |
| ---------- | -------------------------------------------------- |
| dev | concurrently \"npm:dev-client\" \"npm:dev-server\" |
| dev-client | vite |
| dev-server | nodemon server/server.js |
| build | vite build |
| preview | vite preview |
| lint | eslint . |

### 5. Start Editing the App

Edit `/server` folder to edit Backend section. And edit `/src` to start editing the Client page (Frontend).

## Contribution?

Feel free to contribute to this project by opening a pull request.