@shopify/shopify-api - package for access for the Shopify Admin API - read here
express - package for Node.js web framework - read here
dotenv - package for managing environment variables - read here
tsx - package for running TypeScript files - read here
ngrok - tool for creating secure tunnels to localhost, ideal for testing webhooks - read here
We will use ngrok tool to create secure tunnel to our express local server for this get started example.
Step 1 - Install dependencies
npm
yarn
pnpm
bun
Step 2 - Setup connection variables
Create a .env file in the root of your project and add your Shopify Application variables:
tips
If you don’t have a Shopify Application and developer store yet and want to create one for testing, you can use official Shopify guide (Make sure to set up API scopes for your Shopify Application for metaobjects).
After you create Shopify Application you’ll need to get your secret variables, you can use official Shopify manual for it.
The official Shopify guide is available here.
The official Shopify manual to get secrets here.
Step 3 - Declare schema file
Create a schema.ts file and declare your metaobjects and metafields schema:
info
As of now Tento only supports one schema file.
tips
If you don’t have knowledge about Shopify metaobjects and metafields yet, or you want to see full possibilities for those, you can study them on Shopify.
We use port 5000 for our get started example, but you can use any port if you need.
Step 5 - Setup express web app for OAuth
Create a index.ts file and initialize express app. Put hostName and hostScheme variables from ngrok.
This is actually official @shopify/shopify-api OAuth example using express, you can find it here.
Step 6 - Add ngrok link to your Shopify Application
Open Shopify Partners — Login to your account
Click Apps (in the left toolbar) — Click on your App
Click Configuration (in the left toolbar)
Scroll to URLs section and add:
Click Save and Release
Step 7 - Run index.ts file
To run any TypeScript files, you have several options, but let’s stick with one: using tsx
You’ve already installed tsx, so we can run our queries now
Run index.ts script
npm
yarn
pnpm
bun
Step 8 - Open Application in Shopify Store
Open your Shopify Store — Click Apps (in the left toolbar) — Click on your App
info
Wait until Shopify Store get response from your express server. Once it get it, you’ll see this screen.
info
After succeed you can go to Settings — Custom data and find generated Metafields in Products and Designer Metaobject definition