Is there a way to use section id in app block (shopify theme extension)?

Hi,

I want to use the section id where the app block will be rendered in the theme.

Is there a way to use the section id in the app block in the theme extension?

1 Like

Hey!
Did you get the solution for this?

Not yet!

Still no answer to this question? Anyone from Shopify knows if it is possible to get the section ID of an extension app using liquid?

Using Javascript you can get the section ID by doing this in your extension app liquid:

<script>
let sectionId = document.querySelector('#shopify-block-{{ block.id }}').closest('section').id;
</script>

Looks like it’s now possible, just seen this in slack

Good morning, a small update for app blocks. You can now reference the parent section’s ID via {{ section.id }} . Other section attributes aren’t accessible though. This should make it possible to extract the section’s ID without needing to query the DOM when wanting to use the section rendering API from an app block. https://shopify.dev/docs/apps/online-store/theme-app-extensions/extensions-framework#liquid-objects

Moderator Edit