Frontend application for Coastal Elements using Next.js, TypeScript, and Tailwind CSS.
- Node.js v18+
- Backend server running (CE-one-pager-server)
- Supabase account configured
-
Install dependencies:
yarn install # or npm install -
Create
.env.localfile:cp env.example .env.local
-
Configure environment variables:
NEXT_PUBLIC_API_URL=http://localhost:3000/api NEXT_PUBLIC_API_TIMEOUT=10000 NEXT_PUBLIC_ENV=development # Optional (for waitlist only): HUBSPOT_PRIVATE_APP_TOKEN=your_hubspot_token_here
-
Run development server:
yarn dev # or npm run dev
✅ Frontend available at: http://localhost:3001
-
Request OTP:
- User enters email on
/loginpage - Frontend requests OTP from backend
- Backend sends 6-digit OTP to email
- User enters email on
-
Verify OTP:
- User enters OTP code
- Frontend verifies with backend
- Backend returns JWT tokens
- Frontend saves to localStorage and context
-
Protected Routes:
ProtectedRoutecomponent checks authentication- Redirects to
/loginif not authenticated
-
Logout:
- Clears localStorage and context
- Redirects to
/login
import { useAuth } from '../context/AuthContext';
export default function MyComponent() {
const { user, profile, isAuthenticated, logout } = useAuth();
if (!isAuthenticated) {
return <p>Please login</p>;
}
return (
<div>
<p>Welcome, {user.email}!</p>
<p>Credits: {profile.current_credits}</p>
<button onClick={logout}>Logout</button>
</div>
);
}app/
├── lib/
│ └── api-client.ts # API client for backend
├── context/
│ └── AuthContext.tsx # Authentication state
├── components/
│ ├── auth/ # Auth components
│ ├── search/ # Search components
│ └── ...
├── login/
│ └── page.tsx # Login page
├── dashboard/
│ └── page.tsx # Dashboard (protected)
└── waitlist/
└── page.tsx # Waitlist page
NEXT_PUBLIC_API_URL=http://localhost:3000/api
NEXT_PUBLIC_API_TIMEOUT=10000
NEXT_PUBLIC_ENV=developmentHUBSPOT_PRIVATE_APP_TOKEN=your_hubspot_token_hereNote: HubSpot token is only needed for waitlist feature. Authentication works without it.
-
Start Backend:
cd CE-one-pager-server npm run start:dev -
Start Frontend:
yarn dev
-
Test Login:
- Go to
http://localhost:3001/login - Enter email
- Check email for OTP
- Enter OTP
- Should redirect to dashboard
- Go to
-
Test Protected Routes:
- Clear localStorage
- Try accessing
/dashboard - Should redirect to
/login
- Ensure backend is running
- Check
NEXT_PUBLIC_API_URLin.env.local - Verify CORS enabled in backend
- Check Supabase Auth settings
- Verify email provider configuration
- Check spam folder
- Check JWT_SECRET matches backend
- Clear localStorage and login again
- Verify token not expired
The easiest way to deploy is using Vercel Platform.
- Backend: CE-one-pager-server
- API Documentation: See Swagger UI at
http://localhost:3000/docs(when backend running)