How do you build a secure, scalable app as a solo founder without a massive budget? Iβm doing it with AWS Cognito for KaziHub, a smart job board empowering African developers with verified tech jobs, scam detection, and skill-based matching.
In this post, Iβll walk you through how I implemented user authentication with Cognito + React + AWS Amplify β a stack perfect for lean startups looking to scale fast.
π§± Why AWS Cognito?
Cognito is a powerhouse for startups like mine because:
- β Handles user sign-up, login, email verification, and password resets out of the box
- β Scales effortlessly, so I donβt worry about infrastructure as KaziHub grows
- β Integrates seamlessly with AWS services like Lambda, S3, and DynamoDB, which Iβm using for job matching
- β Saves me from building a custom auth backend, keeping costs low and development fast
AWSβs serverless tools are a game-changer for solo founders, letting me focus on KaziHubβs mission: connecting African developers with verified opportunities.
π§ Setting Up Cognito
Create a User Pool
Go to AWS Console β Cognito β User Pools β Create new pool
I enabled email as the sign-in method and applied strong password policies.Set up an App Client
Created a client ID without a client secret (since the frontend is public).Configure the Hosted UI Domain
This allows a seamless experience for verification, sign-up, and password recovery.
π» Setting Up My React Frontend
Install AWS Amplify
npm install aws-amplify
Configure Amplify
// src/awsConfig.js
export const awsConfig = {
Auth: {
region: "us-east-1",
userPoolId: "us-east-1_XXXXXXX", // Replace with your User Pool ID (Based on how close it is to your location to reduce latency)
userPoolWebClientId: "XXXXXXXXXXXXXX", // Replace with your App Client ID
},
};
// main.jsx
import { Amplify } from "aws-amplify";
import { awsConfig } from "./awsConfig";
Amplify.configure(awsConfig);
π§βπ» Auth Flows
π Sign Up
import { Auth } from "aws-amplify";
const handleSignUp = async () => {
await Auth.signUp({
username: email,
password,
attributes: { email },
});
};
π Login
const handleLogin = async () => {
await Auth.signIn(email, password);
};
π Recover Password
await Auth.forgotPassword(email);
await Auth.forgotPasswordSubmit(email, code, newPassword);
β Confirm Sign Up
await Auth.confirmSignUp(email, code);
π Protecting Routes (Optional)
To protect authenticated-only pages (like posting jobs), I created a simple PrivateRoute
component:
const PrivateRoute = ({ children }) => {
const [user, setUser] = useState(null);
useEffect(() => {
Auth.currentAuthenticatedUser()
.then(setUser)
.catch(() => (window.location.href = "/login"));
}, []);
return user ? children : null;
};
π§ Lessons Learned
- AWS documentation can feel dense. Setting up email flows and user pools took trial and error.
-
InvalidParameterException
was my nemesis β usually caused by misconfigured attributes. - Once itβs set up, Cognito just works. Itβs magical watching everything sync across the hosted UI and your frontend.
π Whatβs Next
- Build job posting + application logic using Lambda and DynamoDB
- Add user roles for Job Seekers and Employers
- Set up CI/CD pipeline with GitLab
- Deploy via AWS Amplify Hosting or S3 + CloudFront
π¬ Final Thoughts
AWS Cognito and Amplify have been game-changers for KaziHub. Iβm building a secure, scalable platform for African developers β without having to manage infrastructure or auth complexity.
π Weβve already onboarded 100+ users in beta, and thanks to Cognito, every sign-up, login, and password reset has been smooth.
Got questions or ideas? Ping me on X β happy to connect with fellow builders!
Top comments (0)