Store information for embedded app

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

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,

1 Like

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.