Store information for embedded app

Store information for embedded app

arnav98
Shopify Partner
26 1 7

Hi, 

 

I want the store name inside my embedded app, is there a way to do it without using the REST API.

 

Can it be done via Shopify App Bridge? I saw somewhere it was available in v2 under store information but I can't seem to find it under the getState() now, I am using v3

Replies 2 (2)

Liam
Shopify Staff
2831 311 807

Hi Arnav98,

 

For v3 of the App Bridge, I think you will need to use a REST API endpoint to retrieve the store name. With App Bridge, you can use the `authenticatedFetch` function to make this request securely from your app - it could look something like:

import createApp, { authenticatedFetch } from '@shopify/app-bridge';

const app = createApp({
apiKey: 'your_api_key',
shopOrigin: 'your_shop_origin',
});

const fetchFunction = authenticatedFetch(app);

fetchFunction('/admin/api/2023-04/shop.json').then((response) => {
response.json().then((json) => {
console.log(json.shop.name);
});
});


This code initializes your App Bridge app, then uses the `authenticatedFetch` function to make a GET request to the `shop.json` endpoint. The response is a JSON object, from which you can extract the shop name.

 

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

arnav98
Shopify Partner
26 1 7

Hi, where will I get the 'shop_origin' from? Is this value required to be set in the env file?

 

Also, my app should be able to retrieve the shop name of the store it is installed in.

For now, I have created an API proxy inside node.js and used the REST API to fetch the store information.