A developer is building a Shopify Remix app that conditionally displays a button based on database records. The button should appear only when shop_domain, shop_id, name, and email exist in the database after app installation.
Initial Challenge:
Backend API checks for shop_id, but frontend doesn’t have direct access to this value after installation
Need to determine how to retrieve shop_id from the database for verification
Proposed Solution:
Modified backend API to accept shop domain (available in URL query params) instead of shop_id
API queries database using myshopify_domain to find matching shop record
Frontend loader extracts shop parameter from URL and calls backend API
Conditionally renders button or default template based on API response
Current Issue:
On first installation, “Please register yourself” message appears
After page refresh, button displays correctly but doesn’t navigate to intended URL on click
Developer wants immediate button display if all 4 details save successfully during installation, otherwise show registration message
The discussion remains open with the developer seeking help to fix the post-installation flow and button navigation functionality.
Summarized with AI on October 31.
AI used: claude-sonnet-4-5-20250929.
I want to show button in the place of this template if my “shop_domain, shop_id, name and email” exist in the database. I am using remix when i install the app then the shop collection and session collection saved in db. Now based on that i want to show the button on the Remix Template page if this details are present in my db.
res.status(404).json({ showButton: false, message: ‘Please register yourself’ });
} catch (error) {
res.status(500).json({ error: ‘Internal Server Error’, details: error.message });
}
};
Now from where frontend developer get that shop_id which we get after installing the app and it saved in db by using graphql at the time of afterAuth call. By using that shop_id check other details also existing in db or not, if existing then able to show button by replacing all this below Remix app template otherwise not able to show or i need to perform changes in my api if yes then what
To achieve this functionality in your Remix app, follow these steps:
Retrieve shop_id on the Frontend
After app installation, Shopify provides the shop’s domain (e.g., shop=myshop.myshopify.com) as a query parameter. However, you saved the shop_id in your database, which means you need to fetch it from your backend.
You can store the shop domain in session storage or retrieve it from the database using the authenticated user session.
Modify the Backend API (Optional Fixes)
Your current API works well for checking if shop_id exists, but the frontend does not have shop_id directly after installation. Instead, modify your API to accept shop (the Shopify domain) and fetch the shop_id:
Hello @rajweb Thank you for your support. this working fine, but i got little problem while installing the app first time, it will show message on the UI “Please register yourself” but after refreshing it, then button is showed on ui but clicking on it, it doesn’t refer me where i want to refer on clicking that button.
// routes/index.jsx
import { useLoaderData } from “@remix-run/react”;
export const loader = async ({ request }) => {
const url = new URL(request.url);
const shop = url.searchParams.get(“shop”); // Get shop from query params
if (!shop) {
return { showButton: false, message: “Shop domain is required” };
}
{showButton ? (
window.location.href = "[https://www.youtube.com/results?search_query=script+tags+in+shopify+app](https://www.youtube.com/results?search_query=script+tags+in+shopify+app)"}
>
Get Started
) : (
Remix app template
{message}
)}
);
}, backend code as same as it. i want to refer on button click and if any of details missing then give the message "Please register". and want to handle this after installing the if all the 4 details saved successfully in db then buttonis showed otherwise give "Please register" message.