Stop a snippet from rendering after app is uninstalled

Shopify Partner
4 0 0



When my app is installed, i am creating a snippet using the asset api. And rendering that snippet in the theme.liquid file (by using the asset api to update the theme.liquid file).


My problem is when the app is uninstalled, i lose access and i cannot remove the snippet i had added. So, is there any way to stop a snippet from rendering when my app is uninstalled?


I have noticed that when i uninstall some apps, this message is shown in the DOM

<!-- "snippets/example.liquid" was not rendered, the associated app was uninstalled -->


But i wasn't able to replicate the above behaviour with my app. Even after i uninstalled my app, the snippet was still getting rendered. I am not sure if that is because i was testing in a development store. Can anyone please tell me how to replicate the above behaviour or is there any other way to not render a snippet when app is uninstalled?




Requesting help from @Luke_K  @TyW @Jason 

Replies 2 (2)

Shopify Partner
51 4 13

{% if shop.apps['your-app-handle'] %}
<!-- Your snippet code here -->
{% endif %}


In this example, the shop.apps object is used to check if your app is installed on the current store. If it is, the snippet code will be rendered. If not, the snippet code will be skipped and will not be rendered on the page.

It is important to note that the your-app-handle value in the example code should be replaced with the actual handle of your app.

Greetings Niclas
Senior Front-End Developer
Founder of Niccos Media
Based in Germany
Shopify Partner
4 0 0

Hey @NiccosMedia, I tried your solution. It doesn't seem to work. My snippet is not getting rendered even if the app is installed. 


There doesn't seem to be a property named "apps" on the shop object. It is not mentioned in the documentation as well:

Can you please share any documentation that you referred for the above solution.


If there is any other way to stop the snippet from rendering when the app is uninstalled, please do let me know, it would be of great help