238 votes
1 answers
node.js - How to get URL of shop in Shopify embeded app?
Solution:
All calls to your App provide a shop parameter (and now a host parameter too) ensuring you always know the shopify store using your App. There are zero situations where your App is called without the shop parameter being part of the equation from Shopify.
Undefined asked
637
votes
Answer
Solution:
Okay, so I came up with a solution by myself, but thanks for your help @TwistedOwl and @David Lazar. I post my code here in case anyone has the same problem in the future:
import {useAppBridge} from "@shopify/app-bridge-react";
function DemoPage() {
const bridge = useAppBridge();
const shopUrl = bridge.hostOrigin.replace('https://', '').replace('www.', '');
console.log(shopUrl);
}
Undefined answered
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.