The Next JS 13 Contact Form using APP route – portfolio website
Next.js is a popular React framework for building server-side rendered applications. With the release of Next.js 13, creating a contact form for your portfolio website has become even easier with the APP route feature.
Using the APP route feature, you can create dynamic routes in your Next.js app by creating a function that returns a custom component. This allows you to easily build a contact form page that can handle form submissions without having to create a separate route or page.
Here’s how you can create a contact form using the APP route feature in your Next.js 13 portfolio website:
- Create a new component for your contact form, such as ContactForm.js
- Inside ContactForm.js, create a form component using HTML and add input fields for the user to enter their name, email, subject, and message. You can also add a submit button to handle form submissions.
- Next, create a function that returns the ContactForm component in your app’s pages directory. This function will be used to create the dynamic route for your contact form page.
- Within the function, use the useRouter hook from Next.js to access the router object and create a handleSubmit function to handle form submissions.
- Finally, use the APP Route feature to create a dynamic route for your contact form page and provide a path for users to access the contact form on your portfolio website.
By following these steps, you can easily create a dynamic contact form for your Next.js 13 portfolio website using the APP route feature. This makes it easier for users to get in touch with you and provides a seamless experience for managing form submissions.
Overall, the new Next.js 13 APP route feature makes it even easier to create dynamic routes and handle form submissions in your portfolio website. With its streamlined process and improved flexibility, building a contact form has never been easier.
thank you, thank you, thank you…its easy to pay attention to such a gorgeous woman, you save my day.
For some weird reason I had to format my form data like this:
const data = {
floating_first_name: e.target.elements.floating_first_name.value,
floating_last_name: e.target.elements.floating_last_name.value,
floating_email: e.target.elements.floating_email.value,
message: e.target.elements.message.value,
};
Do you know why?
Hello, thanks for the tutorial. How to send attachment via file input? Does it works with App Router?
What would you recommend to put this portfolio online?
I'm learning many best practices from you, thanks! 😊
Can you please make a full course on next js
😍
Thank you, It's very nice video. 😊
Very nice and nice video
🤩
There is late night but also can be called early morning now! Glad to watch your new video and, good morning for you! 💜❤️😉
thanks for your efforts
🎉🎉🎉🎉
Give me heart 🤥