- Overview
- Features
- Screenshots
- Technologies Used
- Installation
- Important Notes
- Stripe Test Cards
- Back Office
- Contributing
- License
Hotel Booking System is a full-stack web application designed to streamline the process of reserving hotel rooms. This project represents the front office of a hotel reservation management system, offering users an intuitive and user-friendly interface to search, filter, and book available rooms.
This app is built using Next.js for the front-end and Supabase for the database. It integrates several key libraries such as bcrypt for password security, Auth.js for authentication, and Zod for form validation. The system is designed to provide a smooth booking experience with features such as date filtering, sorting by guests and price, and user profile management.
- Homepage with Offers: A dynamic homepage showcasing available offers, hotel description, and a React Leaflet map displaying the hotel location.
- Booking Form: Users can select a date range, and the system will display available rooms for that period.
- Room Sorting: Sorting functionality based on the number of guests and price.
- Detailed Room Pages: Each room has a dedicated page with a detailed description, booking form, and disabled dates for already reserved periods.
- Authentication: The system supports both credential-based login and OAuth with Google and Facebook providers via Auth.js.
- Checkout Process: Users are forwarded to a checkout page after selecting a room. If not authenticated, they are redirected to the login/signup page.
- Profile Management: Users can update their profile, check their reservation history, cancel unconfirmed reservations, and delete past ones.
- Unconfirmed Reservations: All bookings are marked as unconfirmed and can be confirmed upon arrival.
- Compound Components: Reusable and flexible components are implemented for forms, modals, and inputs to ensure better code organization and scalability.
- Next.js: Server-Side Rendering (SSR), Client-Side Rendering (CSR), and API routes.
- CSS: Fully customized styling using pure CSS.
- React Leaflet: For map integration.
- DayPicker: For friendly date selection.
- date-fns: For handling date manipulation.
- Zod: For form validation.
- React Hot Toast: Showing user-friendly feedback for errors, success, and other statuses.
- Memoization: Applied to prevent unnecessary re-renders.
- Compound Components: Utilized to create cohesive and reusable UI components.
- Supabase: Used as the database for storing and retrieving reservation and user data.
- bcrypt: For secure password hashing and comparison.
- Auth.js: For authentication (credentials and OAuth with Google and Facebook).
-
Clone the repository:
git clone https://github.com/OthmaneNissoukin/nextjs-hotel-booking.git cd nextjs-hotel-booking
-
Install the dependencies:
npm install
-
Set up your environment variables:
- Create a
.env.local
file in the root directory and include the following:
# SUPABASE NEXT_PUBLIC_SUPABASE_URL=YOUR-SUPABASE-URL NEXT_PUBLIC_SUPABASE_KEY=YOUR-SUPABASE-PUBLIC-KEY NEXT_PUBLIC_SUPABASE_IMGS_URL=YOUR-SUPABASE-IMGS-BUCKET-URL SUPABASE_JWT_SECRET=YOUR-SUPABASE-JWT-SECRET SUPABASE_SERVICE_ROLE_KEY=YOUR-SUPABASE-SERVICE-ROLE-KEY # NEXTAUTH NEXTAUTH_URL=http://localhost:3000/ AUTH_SECRET=YOUR-AUTH-SECRET # NEXTAUTH GOOGLE PROVIDER AUTH_GOOGLE_ID=YOUR-GOOGLE-AUTH-ID AUTH_GOOGLE_SECRET=YOUR-GOOGLE-SECRET # NEXTAUTH FACEBOOK PROVIDER AUTH_FACEBOOK_ID=YOUR-FACEBOOK-AUTH-ID AUTH_FACEBOOK_SECRET=YOUR-FACEBOOK-SECRET AUTH_TRUST_HOST=http://localhost:3000 # STRIPE PAYMENT STRIPE_SECRET_KEY=YOUR-STRIPE-SECRET-KEY NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=YOUR-STRIPE-PUBLISHABLE-KEY # PRODUCTION URL NEXT_PUBLIC_APP_URL=http://localhost:3000
- Create a
-
Run the development server:
npm run dev
-
Visit http://localhost:3000 to view the app in your browser.
- Database Sessions: Since Supabase is used as the adapter for authentication, expose the
next_auth
schema in the Supabase dashboard to ensure OAuth providers work properly.- More details: https://authjs.dev/getting-started/adapters/supabase
- Payment Integration: Reservations will only be created upon successful payment. A webhook at
localhost:3000/api/stripe-webhook-gateway
handles Stripe events (checkout.session.completed). Register this link in your Stripe dashboard.- More details: https://docs.stripe.com/webhooks
When testing your Stripe integration, you can use the following test card numbers. These cards are specifically for testing purposes and won't charge real money.
Card Number | Card Type | Expiration Date | CVC | Usage |
---|---|---|---|---|
4242 4242 4242 4242 | Visa | Any future date | Any | Successful charge |
4000 0000 0000 0069 | Visa | Any future date | Any | Card declined (insufficient funds) |
4000 0000 0000 0341 | Visa | Any future date | Any | Card declined (lost card) |
5105 1051 0510 5100 | MasterCard | Any future date | Any | Successful charge |
6011 1111 1111 1117 | Discover | Any future date | Any | Successful charge |
Card Number | Card Type | Expiration Date | CVC | Usage |
---|---|---|---|---|
5555 5555 5555 4444 | MasterCard | Any future date | Any | Card declined (incorrect CVC) |
4222 2222 2222 2222 | Visa | Any future date | Any | Successful charge with 3D Secure (ACS) |
4000 0025 0000 3155 | Visa | Any future date | Any | Successful charge (with 3D Secure) |
Card Number | Card Type | Expiration Date | CVC | Usage |
---|---|---|---|---|
4000 0035 0000 0020 | Visa | Any future date | Any | Requires 3D Secure authentication |
Use this card for testing 3D Secure scenarios.
Card Number | Card Type | Expiration Date | CVC | Usage |
---|---|---|---|---|
4000 0035 0000 0010 | Visa | Any future date | Any | Successful charge with 3D Secure |
Card Number | Card Type | Expiration Date | CVC | Usage |
---|---|---|---|---|
4000 0025 0000 3110 | Visa | Any future date | Any | Successful subscription trial payment |
- Live Version: https://nextjs-hotel-booking-back-office.vercel.app/
- Repo: https://github.com/OthmaneNissoukin/nextjs-hotel-booking-back-office
Feel free to submit issues or pull requests. Contributions, suggestions, and improvements are always welcome!
This project is licensed under the MIT License. See the LICENSE file for details.