This is the frontend application for the Tourist Guide project. It is built with Next.js, TypeScript, Tailwind CSS, and Shadcn UI. This app allows tourists to view tours, book guides, and make payments using stripe payment systems.
Live Demo: https://tourist-guide-frontend.vercel.app
- View all tours with details (cover image, price, duration, etc.)
- Book individual guides or tour packages
- Secure payment integration (Stripe / other payment gateway)
- User authentication (login/signup)
- Review system for tours and guides
- Responsive UI with Tailwind CSS
- Safe image loading from Cloudinary & ImgBB with fallback handling
Make sure you have the following installed on your machine:
- Clone the repository
git clone https://github.com/your-username/tourist-guide-frontend.git
cd tourist-guide-frontend- Install dependencies
npm install
# or
yarn install- Set up environment variables
Create a .env.local file in the root directory:
NEXT_PUBLIC_BASE_API=https://your-backend-api.com
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_yourkey
AUTH_SECRET=rtfgdgdfgReplace these values with your actual backend URL and Stripe key.
- Next.js configuration for remote images
Edit next.config.js to allow images from Cloudinary and ImgBB:
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
images: {
remotePatterns: [
{ protocol: "https", hostname: "res.cloudinary.com" },
{ protocol: "https", hostname: "i.ibb.co" },
],
},
};
export default nextConfig;- Run the development server
npm run dev
# or
yarn devOpen http://localhost:3000 in your browser.
Use a SafeImage component to prevent 400 errors for broken or malformed URLs:
import Image from "next/image";
interface SafeImageProps {
src?: string;
alt?: string;
className?: string;
}
export const SafeImage: React.FC<SafeImageProps> = ({
src,
alt,
className,
}) => {
return (
<Image
src={src?.replace(".co.com", ".co") || "/tour-placeholder.jpg"} // auto-fix common ImgBB mistake
alt={alt || "Tour Image"}
fill
className={className || "object-cover"}
onError={(e) => {
(e.target as HTMLImageElement).src = "/tour-placeholder.jpg";
}}
/>
);
};Usage:
<SafeImage src={tour.coverPhoto} alt={tour.title} />- Automatically fixes
.co.com→.coerrors - Uses fallback image if the URL is broken
- Works with Cloudinary and ImgBB
To create a production build:
npm run build
npm start
# or
yarn build
yarn start- App runs on http://localhost:3000 by default
- Make sure your backend API is deployed and reachable
- Do not use
localhostURLs for images in production - Live Demo: https://tourist-guide-frontend.vercel.app
frontend/
│
├─ public/ # Static assets (images, icons, etc.)
├─ src/
│ ├─ app/ # Next.js pages and layouts
│ ├─ components/ # Shared React components
│ ├─ context/ # React contexts
│ ├─ hooks/ # Custom hooks
│ ├─ services/ # API service functions
│ ├─ utils/ # Helper functions
│ └─ styles/ # Tailwind or custom CSS
├─ .env.local # Local environment variables
├─ next.config.js # Next.js configuration
├─ package.json # Project dependencies & scripts
└─ README.md # Project documentation
| Command | Description |
|---|---|
npm run dev |
Run app in development mode |
npm run build |
Build production version |
npm start |
Start production server |
npm run lint |
Lint the code |
npm run format |
Format code using Prettier |
-
400 error on images
- Ensure URLs are correct (no
.co.comtypo) - Add image domains in
next.config.js - Use
SafeImagecomponent to handle broken/malformed URLs
- Ensure URLs are correct (no
-
CORS or API errors
- Ensure
NEXT_PUBLIC_BASE_APIpoints to the deployed backend - Avoid
localhostin production
- Ensure
-
Stripe errors
- Ensure
NEXT_PUBLIC_STRIPE_PUBLIC_KEYis correct - Check backend handling of payment intents
- Ensure
**Ismail Hossain **
- GitHub: https://github.com/ismaileub
- Email: ismail301515@gmail.com