Zack Saadioui
1/26/2025
1
2
3
bash
npx create-next-app shopify-next-app
cd shopify-next-app
1
2
3
bash
npm install axios@0.21.1
npm install @apollo/client graphql
1
.env.local
1
2
SHOPIFY_STOREFRONT_ACCESS_TOKEN='your-token'
SHOPIFY_STORE_DOMAIN='your-store.myshopify.com'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
javascript
export async function fetchProducts() {
const query = `{
products(first: 10) {
edges {
node {
id
title
description
}
}
}
}`;
const res = await fetch(
`${process.env.SHOPIFY_STORE_DOMAIN}/graphql.json`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Storefront-Access-Token': process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN
},
body: JSON.stringify({ query })
}
);
const data = await res.json();
return data.data.products.edges;
}
Copyright © Arsturn 2025