Why do Shopify Functions provide an unfair advantage to create exceptional stores?
1 – What is a Shopify Function?
Shopify Function allows Shopify app developers to write custom serverless functions that can be executed in response to certain events or triggers and alter the backend logic of Shopify, opening unlimited possibilities for customizations.
e.g., You have an input (for example, a cart), and you return an output (a discount) you want, according to what you have coded in your function depending on the Function API your target. It's like a module in
@make_hq (or your old math lessons): So pretty easy to develop with
2 – What are the advantages of Shopify Functions?
- You are closer to the business logic of Shopify, so you don't need a workaround that will take you a lot of code time to achieve your goals. I made a bundled app based on coupons; now, some logic can be abstracted with Functions.
- The functions are serverless so Shopify handles all the server load; if you have merchants with huge traffics, the AWS bill will sting less.
- You can iterate easier. Each function is a brick of your application, more easily maintainable.
- You can directly use meta fields to store data instead of using your database and storing dynamic values while providing a GUI for merchants
3 – How to create Shopify Functions
You must choose a language that compiles in WASM. I came from Typescript, So I chose
@AssemblyScript; you can also use Rust or Golang. It will soon be possible to use Typescript with the Shopify compiler (javy) in production.
So if you are patient, wait for JS, even if I think it's better to dig into the documentation and try to code quickly
PS: check @grain_lang actively
Polyglot Functions based on Discount Tutorial: https://github.com/nickwesselman/polyglot-functions/tree/main/extensions…
The tutorial to understand everything: https://shopify.dev/docs/apps/discounts/experience…
Thanks for reading, and I hope you found this article useful! Considering the density of things to say, I'll make several articles on the Shopify Functions.