DEV Community

Cover image for Shopify App - Theme Extension with React + Tailwind CSS
iskurbanov
iskurbanov

Posted on • Edited on

Shopify App - Theme Extension with React + Tailwind CSS

Full course available now! πŸ‘‰ Shopify App Development Crash Course

In the last few years Shopify has been revamping their App CLI and all the tooling.

We now have the App Theme Extensions here to replace the Script Tag API and make it an improved experience for merchants and their customers.

Since these upgrades are so new, there is hardly any tutorials on it!

I am currently building a theme extension app for Shopify. I initially started with Vanilla JS and regular CSS but soon realized that I wouldn't be able to build the customer experience that I wanted to with those tools. Plus it would be a bad developer experience for me also.

So about 25% way through the project I decided to switch to React and Tailwind CSS for the Theme Extension. However, this wasn't so easy to setup. So I want to share the process with you in this walkthrough!

Full Tech Stack:

  • Shopify App CLI
  • Vite
  • Theme Extension
  • React + Tailwind CSS

Step 1: Clone Template Extension App

Extension Template Github Repo

Step 2: Create a test store

In your Shopify Partner Account (it's free), create a test store.

Step 3: Run the app and install it



cd your-app-name && npm install


Enter fullscreen mode Exit fullscreen mode

Go through all the installation instructions

Step 4: Deploy the extension



npm run deploy


Enter fullscreen mode Exit fullscreen mode

Step 5: Check the Deployment

Go to the Shopify Partner Dashboard -> Apps -> Versions

And check that the Shopify app was deployed with the extension.

Step 6: Enable Extension on Store

Run



npm run dev


Enter fullscreen mode Exit fullscreen mode

Install the app by clicking on the link in #1. Then go to link in #2 and navigate to the contact page in the theme. Then select the app from the

Install the App

Add the Extension in the Sections
Add Extension Section

See the text "Hello From React!" on your page!
See the text

Great! You now should have a working Shopify App Theme Extension that you can work on! πŸŽ‰ πŸŽ‰ πŸŽ‰

Latest comments (45)

Collapse
 
ajay_yadav_23909e0f8f07eb profile image
Ajay Yadav

Really well-written! While most people focus on the technical implementation of Shopify app theme extensions with React and Tailwind CSS, I’ve seen an interesting take on balancing performance optimization with design flexibility in this guide: mobisoftinfotech.com/services/shop... .

Curious to hear what you think about integrating custom Shopify website design strategies alongside modern front-end frameworks to enhance both user experience and conversion rate optimization!

Collapse
 
leoso5 profile image
Leo-so5

how to get access_token in this app

Collapse
 
galang_ananda_c92ad3ecbc2 profile image
Galang Ananda

Getting an error after npm run dev, is there any fix ?

Image description

Collapse
 
zain_ahmadkhan_0d921ce9a profile image
Zain Ahmad Khan • Edited

The CSS no longer applies in the sample project extension side, did Shopify change something? @iskurbanov

Collapse
 
zain_ahmadkhan_0d921ce9a profile image
Zain Ahmad Khan

Nevermind, I found the solution here
github.com/iskurbanov/theme-app-ex...

Collapse
 
nmy1095 profile image
Nathan Yang

Hi @iskurbanov, thanks for the detailed guide. I'm running into this error after running npm run dev. Have you encountered this before? My ruby version is ruby 3.3.3. if that's useful.

Image description

Collapse
 
iffikhan30 profile image
Irfan

Hey @iskurbanov ,

// Handle GET request
app.get("/apps/proxy", async (_req, res) => {
console.log("GET API");
try {
console.log("trying...");
res.status(200).send({ message: "Got it" });
} catch (error) {
res.status(500).send(error.message);
}
});

When i hit the URL without shopify.validateAuthenticatedSession() it work fine, but when I call on my component

const textProxy = (d) => {
return new Promise((resolve, reject) => {
fetch("SHOP-URL/apps/proxy", {
method: 'POST',
redirect: 'manual',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
body: JSON.stringify(d)
})
.then(response => {
console.log(response, 'response');
return response; // Assuming the response is in JSON format
})
.then(data => {
resolve(data);
})
.catch(error => {
reject(error);
console.log("test", error);
});
});
};

its show me 404 error, I am stuck please!

Collapse
 
dark_knight profile image
Harsh Arora

Can i create multiple app blocks in same extenison using react? Also how can i pass data from liquid to react app if i have some block settings?

Collapse
 
notrealdev profile image
notrealdev

Hi, is there any way to transfer the newly created section to Shopify section?
Like this image?
Image description

Collapse
 
jnsrst profile image
Jonas Ernst • Edited

Hi @iskurbanov
how would you integrate settings from the editor into the react code? For example i want to implement an image picker setting.

  1. Where would i put this setting?
  2. How would i get this image into the react code?

Thanks a lot!

Collapse
 
iskurbanov profile image
iskurbanov

Hey Jonas, you can easily do this by just passing them as data- attributes in the root div. Something like this:

Image description

Collapse
 
vmhoang0306 profile image
vmhoang0306

After completed the cmd npm run dev, my terminal don't show me link to install app in step 6.
In addition, i have this error

Image description

can you help me?

Collapse
 
iskurbanov profile image
iskurbanov

Maybe you need to run "shopify login" to connect your app to your partner account.