-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Many frameworks these days are migrating to a server-side renderred approach with their apps - Since loadDefaultJapaneseParser() requires the window object to load, it's currently unusable on Hydrogen.
Below is a screenshot of a mock Hydrogen store which breaks when using any parser.
ReferenceError: window is not defined
Steps to reproduce:
-
Create a new Hydrogen storefront.
npm create @shopify/hydrogen@latest
In your terminal, create a new Hydrogen project using example data from Mock.shop
https://shopify.dev/docs/storefronts/headless/hydrogen/getting-started -
Run the dev serverAnchor link to section titled "Step 2: Run the dev server"
After installation, open your new project and start the dev server:cd hydrogen-quickstart shopify hydrogen devOnce the dev server is running, open http://localhost:3000/ in your browser and you'll see Mock.shop
-
Add budoux to the project.
npm install budoux
-
Navigate to file
/app/routes/_index.tsx(Home page) -
Update the loader function by adding the parser:
export async function loader(args: LoaderFunctionArgs) { const parser = loadDefaultJapaneseParser(); // Start fetching non-critical data without blocking time to first byte const deferredData = loadDeferredData(args); // Await the critical data required to render initial state of the page const criticalData = await loadCriticalData(args); return defer({...deferredData, ...criticalData}); }
-
Open http://localhost:3000/ in your browser and you'll see the error.
