Connecting Xano and Webflow: A Guide to Handling Form Submissions
In the world of modern web development, the ability to create powerful, database-driven websites without extensive coding is a game-changer. Two platforms at the forefront of this revolution are Webflow, a visual web design tool, and Xano, a no-code backend development platform. When combined, they offer a robust solution for creating dynamic websites with sophisticated data management capabilities.
One common use case for this integration is handling form submissions. Here's a streamlined process to connect your Webflow forms to a Xano backend:
Set Up Your Xano Backend: Begin by creating a database table in Xano to store your form submissions. Then, create an API endpoint that accepts
POST
requests containing the form data. This endpoint will serve as the bridge between your Webflow form and your Xano database.Configure Your Webflow Form: In Webflow, design your form as usual. Then, in the form settings, set the action to your Xano API endpoint URL. This tells Webflow where to send the form data.
Implement Custom Code: To ensure a smooth user experience and handle the form submission process more effectively, add a custom code snippet to your Webflow site. This JavaScript code will intercept the form submission, send the data to Xano via an AJAX request, and handle the response.
Create a Transition Effect: For an extra touch of polish, implement a transition effect after successful form submission. This can be achieved using animation libraries like GSAP, creating a visually appealing experience as the user is redirected or shown a success message.
Test and Refine: Thoroughly test your form submission process, ensuring data is correctly sent to Xano and stored in your database. Refine the user experience based on these tests, adjusting error handling and success messages as needed.
Leveraging AI for Code Generation:
One of the most exciting developments in this space is the ability to use AI, like Claude, to generate the necessary code for connecting Xano and Webflow. By providing Claude with specific requirements, such as the need for a form submission handler with a custom transition effect, you can quickly obtain a working code snippet.
For example, you might prompt Claude with: "I need JavaScript code to handle a Webflow form submission, send the data to a Xano API, and create a transition effect using GSAP after successful submission."
Claude can then generate a code snippet that includes:
Event listeners for form submission
AJAX requests to the Xano API
Error handling
GSAP animations for a smooth transition effect
This AI-assisted approach significantly reduces the time and expertise needed to implement complex functionality. It allows designers and entrepreneurs to focus on their core product while still implementing sophisticated features.
By following these steps and utilizing AI assistance, you create a seamless connection between your Webflow front-end and Xano back-end. This integration allows you to collect and store form data efficiently, opening up possibilities for further data processing, automated responses, or integration with other services.
The beauty of this setup lies in its flexibility and scalability. As your needs grow, you can easily expand your Xano backend to handle more complex data operations, all while maintaining the visual design control that Webflow offers.
This approach uses Webflow and Xano without Wized. But another way to connect your webflow form to xano is through Wized. We will touch on that another time.
Below is the code snippet used on my contact page to send the form data to xano and animate on form submission.
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Create transition overlay
const overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.top = '0';
overlay.style.left = '0';
overlay.style.width = '100%';
overlay.style.height = '100%';
overlay.style.backgroundColor = 'transparent';
overlay.style.zIndex = '9999';
overlay.style.pointerEvents = 'none';
document.body.appendChild(overlay);
// Create circles
const circleCount = 5;
const circles = [];
for (let i = 0; i < circleCount; i++) {
const circle = document.createElement('div');
circle.style.position = 'absolute';
circle.style.borderRadius = '50%';
circle.style.backgroundColor = '#725f73';
circle.style.width = '20px';
circle.style.height = '20px';
circle.style.transform = 'scale(0)';
overlay.appendChild(circle);
circles.push(circle);
}
const form = document.querySelector('form'); // Adjust selector if needed
form.addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(form);
const data = Object.fromEntries(formData);
fetch('PLACE-YOUR-XANO-ENDPOINT-HERE', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then(response => response.json())
.then(result => {
console.log('Success:', result);
// Position circles randomly
circles.forEach(circle => {
circle.style.left = `${Math.random() * 100}%`;
circle.style.top = `${Math.random() * 100}%`;
});
// Animate circles and transition to new page
const tl = gsap.timeline();
tl.to(circles, {
scale: 50,
duration: 1,
stagger: 0.1,
ease: "power2.in",
})
.to(overlay, {
backgroundColor: '#725f73',
duration: 0.2,
onComplete: () => {
window.location.href = 'https://www.danielmigizi.com/';
}
}, "-=0.5");
})
.catch(error => {
console.error('Error:', error);
alert('There was an error submitting your form. Please try again.');
});
});
});
</script>
Here's a walk-through of what's happening in the above code:
First, the script loads the GSAP (GreenSock Animation Platform) library from a CDN.
The code waits for the DOM to be fully loaded before executing (using
DOMContentLoaded
event).It creates a full-screen overlay:
A
div
element is created and styled to cover the entire viewport.It's initially transparent and doesn't interfere with user interactions.
Next, it creates 5 circle elements:
Each circle is a
div
styled to be round and colored #725f73.They're initially invisible (scaled to 0) and positioned absolutely within the overlay.
These circles are stored in an array for later use.
The script then finds the form on the page and adds a submit event listener.
When the form is submitted:
The default form submission is prevented.
Form data is collected and formatted.
A fetch request is made to submit the form data to a Xano API endpoint.
If the submission is successful:
The circles are randomly positioned across the screen.
A GSAP timeline is created for the animation sequence.
The circles are animated to scale up dramatically (50 times their original size).
The animation is staggered, so each circle starts its animation slightly after the previous one.
After the circles have mostly covered the screen, the overlay's background color is set to #725f73 to fill any gaps.
Once the animation completes, the page redirects to the homepage.
If there's an error in form submission:
An error is logged to the console.
An alert is shown to the user.
This code creates a visually interesting transition effect after a successful form submission, where circles expand from random points on the screen to cover it before redirecting to a new page. The effect is smooth and engaging, providing visual feedback for the form submission process.
Subscribe to my newsletter
Read articles from Daniel Migizi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Daniel Migizi
Daniel Migizi
π€Όπ¨π»βπ» Retired athlete turned Product Engineer, passionate about building on the web using Visual Development tools and AI.