4 ms·
Does Next SSR like this also submit traditional web forms and handle them server side? Or would that count as the 20% that's unsupported?
by paulryanrogers 4y ago
Does Next SSR like this also submit traditional web forms and handle them server side? Or would that count as the 20% that's unsupported?
- solardev 4y agoI would say forms are an adjacent technology. There is nothing inherent in React or JS that would either magically make or break forms. A form is just an bunch of input fields and a submit handler. If you write your fields as real HTML input fields (instead of, say, weird bespoke divs that happen to have key handlers, yuck), you can still add JS to them for autocomplete and validation and such. But they'll still work without JS. The other part is the submit handler. If you capture the submit button onclick to do something (like submit it using AJAX) then that won't work. But it's easy to add a HTTP POST fallback, and honestly that should be a best practice with or without Next. It's been like that since the jQuery days and before. Beyond that, I can't think of anything specifically involved in SSR that would affect forms. Have an example? Edit 1: If you're using a third-party module/framework/service to create a form, whether it will work with JS depends on its specific implementation. The MUI framework, for example, has higher-order form input abstractions (like the <Input> component here https://mui.com/base/react-input/#introduction https://mui.com/base/react-input/#introduction) that depend on React and JS, but are really just wrappers around the HTML <input> element. It will still accept text without JS, just lose some of its secondary features. On the other hand, with something like Typeform... I couldn't even get the actual form to load without JS enabled: https://www.typeform.com/templates/t/demo-feedback-form-template/ https://www.typeform.com/templates/t/demo-feedback-form-temp... Edit 2: I thought of another way to interpret your question. In addition to the frontend parts of Next, which the above addresses, Next also has API endpoints and edge functions that can act as form handlers if you want them to. That only works if you're hosting on a live Node server (like Vercel), not if you're baking to static clientside HTML for CDN distribution. (The difference between `next start` and `next build`) But that's kinda a tortured way to deal with form submissions. Usually the webforms would POST to someplace that's a preexisting business requirement (a Salesforce or Hubspot endpoint, for example, or even an email address), so you don't really have to use the Next middleware to handle submissions. You COULD do that in Next if you really wanted to, but I wouldn't myself... it would just be reinventing the wheel for no good reason.
- onion2k 4y agoThat depends on how the dev building the site writes them. They can work but they usually don't.