This project demonstrates how to build user authentication (login and signup) using Vercel Edge Functions integrated with a Next.js app. The app allows users to sign up and log in, while Vercel handles the serverless edge functions, ensuring fast and low-latency requests.
- Login and Signup functionality.
- Serverless Edge Functions deployed on Vercel.
- Seamless integration with Next.js for the frontend.
Key Characteristics:
- Low Latency: Processes requests closer to the user's location.
- Dynamic Rendering: Enables real-time updates and personalized content.
- Scalability: Automatically scales to handle high traffic.
-
Node.js: Download Node.js (LTS version is recommended)
-
npm: Comes installed with Node.js.
-
Vercel CLI: Install globally with:
npm install -g vercel
git clone https://github.com/Keval9247/Edge-Function-with-Vercel.git
cd Edge-Function-with-Vercel
npm install
To run your Next.js app with edge functions locally:
vercel dev
Visit http://localhost:3000 to view the app in your browser.
This edge function handles the login process by validating the provided email and password.
-
Request Type: POST
-
Request Body:
{
"email": "example@example.com",
"password": "password123"
}
Response :
- Success:
{
"message": "Login successful!"
}
This edge function handles the signup process, allowing users to create a new account.
-
Request Type: POST
-
Request Body:
{
"email": "newuser@example.com",
"password": "newpassword123"
}
Response :
- Success:
{
"message": "Signup successful! Please check your email for verification."
}
If the edge function is not working correctly, check the logs in the Vercel dashboard for error details. 📜
Ensure the frontend and backend are correctly connected and verify that the API endpoints are returning the expected responses. 🔍
Run npm install
to ensure all necessary packages are installed. 🔄
To support the development of this project or gain access to more resources, you can use our referral link:
https://egde-function.vercel.app/
Use this link to sign up and support the ongoing development of this project. Thank you! 🙏