Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi, I have an embedded app 58128990209, and I have turned on its embedded option in app configuration.
The app has been successfully embedded in Shopify Admin console, but the App Bridge doesn't work for me. When I access the react hook of useAppBridge, I can console the config as (don't worry about data leak, it's a test app):
Not sure what's wrong with this Shopify hook, but Shopify nav-menu, and Toast doesn't give me any result.
I have this script added to my root:
And AppBridge react code:
Is that possible the host string is incorrect ? How to debug this. Thank you so much !
Ensure that the App Bridge is correctly set up before trying to use it.
import { AppProvider } from '@shopify/app-bridge-react';
import { BrowserRouter as Router } from 'react-router-dom';
const config = {
apiKey: 'e81f321eaf4ca36c21090d47f695c86e',
host: new URLSearchParams(window.location.search).get('host'),
forceRedirect: true,
};
root.render(
<AppProvider config={config}>
<Router>
<React.StrictMode>
<NavMenu>
<a href="/" rel="home">Home</a>
<a href="/templates">Templates</a>
<a href="/settings">Settings</a>
</NavMenu>
<ApolloProvider client={client}>
<App />
</ApolloProvider>
</React.StrictMode>
</Router>
</AppProvider>
);
App Bridge is imported correctly:
import { useAppBridge } from '@shopify/app-bridge-react';
import { Toast } from '@shopify/app-bridge/actions';
const MyComponent = () => {
const app = useAppBridge();
useEffect(() => {
const toast = Toast.create(app, { message: 'Test success' });
toast.dispatch(Toast.Action.SHOW);
}, [app]);
return <div>My Component</div>;
};
export default MyComponent;
If this fixed your issue, likes and accepting as a solution are highly appreciated.
Build an online presence with our custom built Shopify Theme EcomifyTheme
Thanks for your response. It seems your solution is identical to my code. I am using the latest version https://shopify.dev/docs/api/app-bridge-library#react so you no longer need to declare provider. as long as you add:
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024