how to give javascript variable to my liquid file to render product data

Topic summary

A developer is attempting to pass a JavaScript variable into a Liquid template file to render product data in Shopify.

Core Issue:

  • Direct use of JavaScript variables inside Liquid files is not possible due to how these templating systems work (Liquid renders server-side, JavaScript executes client-side).

Proposed Alternatives:

  • The original poster asks about using an API as a workaround.
  • They express concern about theme distribution: if selling the theme, buyers would need to modify frontend Shopify API keys in the code.

Status:

  • The discussion remains open with no definitive solution provided yet.
  • The poster is seeking guidance on the correct approach for this scenario.
Summarized with AI on November 3. AI used: claude-sonnet-4-5-20250929.

What the alternative solution can we use any API for that, if yes then if i sell my theme to any user then he have to change shopify frontend API key from code. Suggest the correct way.