This is a simple Next.js demo app that shows how to send user input to an API route, process it on the server, and display the processed result on the UI. It also demonstrates how to forward the data to an external webhook endpoint.
- Collects user input (name, message, user ID) via a form.
- Sends the input to a Next.js API route (
/api). - The API processes the data and returns:
- The original name, message, and user ID.
- The current date/time.
- The processed data is displayed back to the user after submission.
- The API also forwards the raw data to a webhook.site endpoint for demonstration.
src/app/
├── api/
│ └── route.ts # API route for processing and forwarding data
├── dashboard/
│ └── page.tsx # Dashboard page with the form and result display
├── globals.css # Global styles (Tailwind CSS)
├── layout.tsx # Root layout
└── page.tsx # Home page with link to dashboard
- User visits
/dashboardand fills out the form. - On submit, the form data is sent to
/apivia a POST request. - The API route:
- Reads the JSON body.
- Adds the current date/time.
- Forwards the original data to a webhook endpoint.
- Returns the processed data (name, message, userId, time) as JSON.
- The dashboard page receives the response and displays the processed data.
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Open your browser:
Visit http://localhost:3000 and click "Open Dashboard" to try the demo.
-
Webhook Endpoint:
The webhook URL insrc/app/api/route.tscan be changed to any endpoint you want to test with. -
Styling:
Uses Tailwind CSS for quick and easy styling. You can adjust styles inglobals.cssor directly in the components.
- Go to
/dashboard. - Enter a name, message, and user ID.
- Submit the form.
- See your input and the generated date/time displayed below the form.
This project is for demonstration and learning purposes. It is not intended for production use.