Happening now! Shopify Community AMA: Building a Marketing Budget with 2H Media | Ask your marketing budget questions now!

Where is the initial logic after app gets installed

Where is the initial logic after app gets installed

12345vb
Shopify Partner
11 0 2

I would like to create some initial entires in my database right after the app is installed. Although I can't seem to find the location for that. I was looking at other people's custom code and they added it right when oAuth was successful. I don't see any option for that in this repo, seems like it's all behind the scenes. 

I am using React/NodeJS from Shopifys App Tutorial. My git files basically look the same as the template: https://github.com/Shopify/shopify-app-template-node/tree/cli_three 
I was thinking putting it somewhere in `/web/index.js` but that might be a bad spot.

An alternative would be on the root page "/" of react, do an API call then and check if the data is present. Although this option is not the greatest. 

 

(I have the Api call all hooked up and working, I just need a location of WHERE to dump this function RIGHT AFTER the app initially installs. Ideally, only called ONCE) 

Reply 1 (1)

oscprofessional
Shopify Partner
16344 2438 3180

Hello @12345vb 
Most suitable location is -
i) where shopify API initialize (e.g.Shopify.Context.initialize) please refer screenshot -

oscprofessional_1-1667294411906.png

 

ii) in "auth/callback" route with some conditional statement.

 

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...