The Force Dowels application uses Clerk for authentication, providing secure user management with custom-styled sign-in and sign-up pages.
The authentication system provides:
- Custom sign-in and sign-up pages
- Route protection middleware
- User session management
- Seamless integration with the application design
- Mobile-responsive authentication flows
- Sign-In: Users can sign in or sign up from the same page (
/sign-in) - Sign-Up: Dedicated sign-up page available at (
/sign-up) - Redirects: Proper fallback redirects configured
- Protection: Sensitive routes are protected by middleware
- Location:
app/sign-in/[[...sign-in]]/page.tsx - Features:
- Combined sign-in/sign-up flow using Clerk's
<SignIn />component - Custom styling with amber theme to match Force Dowels branding
- Patent Pending notices for brand consistency
- Responsive design
- Combined sign-in/sign-up flow using Clerk's
- Location:
app/sign-up/[[...sign-up]]/page.tsx - Features:
- Dedicated sign-up page using Clerk's
<SignUp />component - Consistent styling with sign-in page
- Patent Pending branding elements
- Responsive design
- Dedicated sign-up page using Clerk's
- File:
middleware.ts - Implementation: Uses
createRouteMatcherfor route protection - Public Routes:
/(homepage)/sign-inand/sign-up(authentication)/contact(contact form)/find-a-distributor(distributor finder)/distributor-application(distributor applications)/privacy-policyand/terms-of-service(legal pages)/videos(product videos)/faq(frequently asked questions)- API routes for public functionality
/order- Product ordering/profile- User profile management/checkout- Payment processing
- File:
components/header.tsx - Changes:
- Replaced modal-based auth buttons with navigation links
- Updated both desktop and mobile navigation
- Maintained existing UserButton for authenticated users
- Preserved all existing functionality
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your_clerk_key
CLERK_SECRET_KEY=sk_test_your_clerk_secret
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/- Create Application: Set up new application in Clerk dashboard
- Configure URLs:
- Sign-in URL:
/sign-in - Sign-up URL:
/sign-up - After sign-in URL:
/ - After sign-up URL:
/
- Sign-in URL:
- Allowed Origins: Add your domain(s)
- API Keys: Copy publishable and secret keys
- Amber Theme: Consistent with Force Dowels brand colors (#d97706, #f59e0b)
- Patent Pending: Notices included on auth pages
- Responsive: Works on all device sizes
- Typography: Matches existing site design
The authentication components use Clerk's appearance customization:
appearance={{
elements: {
formButtonPrimary: 'bg-amber-600 hover:bg-amber-700',
card: 'shadow-lg border-amber-100',
headerTitle: 'text-amber-900',
// Additional custom styles...
}
}}- Auth buttons in header navigate to custom pages
- Fast loading with Next.js App Router optimization
- Error handling managed by Clerk
- Fully accessible components
- Responsive design for all screen sizes
- Touch-friendly interface
- Optimized for mobile browsers
- Consistent experience across devices
- ✅ Sign-in page loads correctly at
/sign-in - ✅ Sign-up page loads correctly at
/sign-up - ✅ Header navigation buttons work properly
- ✅ Middleware protects routes correctly
- ✅ No console errors
- ✅ Responsive design works on all screen sizes
- Sign-up Flow: Create new account and verify email
- Sign-in Flow: Log in with existing credentials
- Route Protection: Try accessing protected routes without auth
- Session Management: Verify session persistence
- Sign-out: Test sign-out functionality
Configure in Clerk dashboard:
- Google OAuth
- GitHub OAuth
- Facebook OAuth
- Apple OAuth
Customize Clerk's email templates:
- Welcome emails
- Password reset emails
- Email verification
- Magic link emails
Set up webhooks for:
- User creation events
- User updates
- Session events
- Organization events
Authentication Not Working
- Verify API keys are correct
- Check environment variables are loaded
- Ensure Clerk dashboard configuration matches
Redirect Issues
- Verify redirect URLs in Clerk dashboard
- Check middleware configuration
- Ensure environment variables are set
Styling Problems
- Check Tailwind CSS classes are loading
- Verify custom appearance configuration
- Test on different screen sizes
- Check browser console for errors
- Verify network requests in developer tools
- Check Clerk dashboard logs
- Test with different browsers
- Verify environment variables
- Test Authentication: Try signing up and signing in with real credentials
- Customize Further: Add additional branding or custom fields if needed
- Configure OAuth: Set up social login providers in Clerk dashboard
- Email Templates: Customize Clerk's email templates to match branding
Access your Clerk dashboard to:
- Configure additional authentication methods
- Customize email templates
- Set up webhooks
- Monitor user activity
- Configure organization features
The authentication implementation is complete and ready for production use!