NextJS Templates

Meeting Room Booking App Tutorial with Back4App, Next.js and Vercel

23min

In this tutorial, you will build Bookit, a meeting room booking system using Next.js as the frontend framework and Back4App as the backend service. You will implement user authentication, room management, and booking functionality, and deploy the app on Vercel.

1. Prerequisites

To complete this tutorial, you will need:

2. Setting Up Back4App

  1. Log in to your Back4App account and navigate to your project dashboard.
  2. In the left sidebar, click Database to access the Data Browser.
  3. You will need to create the following classes to model the data:

2.1. Create the User Class

By default, Parse handles user authentication, so no need to create this class manually. Parse automatically manages the following fields for you:

  • email: Email address for login
  • password: Password (hashed)
  • username: Optional username

2.2. Create the Room Class

  1. In the Data Browser, click Create a Class, select Custom, and name the class Room.
  2. Add the following columns:

Column Name

Type

Description

name

String

Room name

description

String

Room description

capacity

Number

Number of people the room can hold

amenities

Array

List of amenities (TV, WiFi, etc.)

price

Number

Price per hour

image

File

Image URL

owner

Pointer

Points to the User class

2.3. Create the Booking Class

  1. Create another custom class named Booking.
  2. Add the following columns:

Column Name

Type

Description

room

Pointer

Points to the Room class

user

Pointer

Points to the User class

checkIn

Date

Start date/time of the booking

checkOut

Date

End date/time of the booking

3. Setting Up Next.js and Parse SDK

  1. Create a new Next.js project:
Bash

  1. Install Parse JS SDK:
Bash

  1. In the pages/_app.js file, initialize Parse with your Back4App credentials:
JS


Replace 'YOUR_APP_ID' and 'YOUR_JAVASCRIPT_KEY' with your Back4App app credentials.

4. Implementing User Authentication

4.1. User Registration

Create a new page pages/signup.js with a registration form:

JS


4.2. User Login

Create pages/login.js for user login:

JS


4.3. Protected Routes

For protected routes, you can use Next.js API routes and check if the user is authenticated:

JS


5. Room Management

5.1. Displaying Available Rooms

Create pages/index.js to list available rooms:

JS


5.2. Adding a Room

Create pages/add-room.js for adding new rooms (for authorized users):

JS


5.3. Room Details

Create pages/rooms/[id].js to view detailed information about a room:

JS


6. Booking System

6.1. Booking a Room

Add booking functionality in pages/rooms/[id].js by adding a booking form:

JS


6.2. Viewing and Canceling Bookings

Create pages/my-bookings.js to view and cancel bookings:

JS


7. Deploying to Vercel

  1. Install the Vercel CLI:
Bash

  1. Deploy your Next.js app with:
Bash


Follow the prompts to deploy your app to Vercel. Once deployed, your app will be live on a public URL.

8. Conclusion

In this tutorial, you built a Bookit app with Next.js for the frontend and Back4App as the backend. You implemented user authentication, room management, and booking functionality. Finally, you deployed the app on Vercel. You can now expand the app with additional features like search, payment integration, or notifications.