Connecting a Shopify Storefront form with my App

Connecting a Shopify Storefront form with my App

10 0 1

I'm having a lot of trouble trying to figure out how to connect a form in the Shopify Storefront with my App. The data from the form will be used to create a metafield. One answer here said that you can either send the information over ajax to a URL endpoint created in your private app or use an App Proxy. I don't fully understand how to do either of these things yet.


The main thing I'm confused about is what URL I should use for the action of the form. For now, I'm just hosting the app on my computer with ngrok, so would I use the link it provides when I run Shopify App Serve plus the router path?


<form action="https://[randomnumbers]">
  <!-- form stuff -->


Or would the store need to be part of the URL?


And then on the server side (I created the app with the Shopify CLI), would I make a new route in the server/server.js file? Something like this:"/foobar", async (ctx) => {
  // create metafield here



If anyone knows of any tutorials going over this, that would be very helpful.

Replies 0 (0)