Getting Started
This guide will help you set up and run your Shopify app using the Vue.js template.
Upgrading from v2? If you have an existing v2 app you want to upgrade, please refer to our migration guide for a smooth transition to v3.
Prerequisites
Before you begin, ensure you have:
- Node.js >=18.0.0
- npm or pnpm
- A Shopify Partner account
- Basic knowledge of Vue.js and Shopify app development
Quick Start
Clone the repository
bash# Option 1: Using degit (recommended) npx degit Mini-Sylar/shopify-app-vue-template your-app-name # For typescript npx degit Mini-Sylar/shopify-app-vue-template#typescript your-app-name
Install dependencies
bashcd your-app-name npm install
Configure your app
bashnpm run dev:reset
This will guide you through:
- Creating a new app in your Shopify Partner dashboard
- Setting up API credentials
- Configuring app scopes
- Setting up development URLs
Start development server
bashnpm run dev
Project Structure
root/
├── client/ # Frontend Vue app
│ ├── src/
│ │ ├── assets/ # Static assets
│ │ ├── components/ # Vue components
│ │ ├── plugins/ # Vue plugins
│ │ ├── router/ # Vue Router config
│ │ ├── stores/ # Pinia stores
│ │ └── views/ # Page components
│ └── vite.config.js # Vite configuration
├── server/ # Backend Node.js app
│ ├── database/ # Database configuration
│ ├── middleware/ # Express middleware
│ ├── routes/ # API routes
│ └── webhooks/ # Webhook handlers
└── shopify.app.toml # Shopify app configuration
Available Scripts
Command | Description |
---|---|
npm run shopify | Run Shopify CLI commands |
npm run build | Build frontend and backend |
npm run dev | Start development server |
npm run dev:reset | Reset Shopify configuration |
npm run dev:webhook | Trigger webhook (use with /api/webhooks ) |
npm run info | Display app info |
npm run generate | Generate theme extension |
npm run deploy | Deploy the app |
npm run show:env | Show production environment variables |
npm run lint | Lint entire project |
npm run lint:server | Lint server code |
npm run lint:client | Lint client code |
npm run format:server | Format server code |
npm run format:client | Format client code |
Development Workflow
1. Frontend Development
The frontend uses Vue 3 with the Composition API. Key features:
vue
<script setup>
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { storeToRefs } from 'pinia'
import { useProductStore } from '@/stores/products'
// Internationalization
const { t } = useI18n()
// State management
const { products } = storeToRefs(useProductStore())
// Component logic
const isLoading = ref(false)
</script>
2. API Integration
The template provides authenticated API access:
js
// Fetching data from Shopify
const response = await fetch('/api/products/count')
const data = await response.json()
3. Webhook Development
Create webhook handler:
js// web/server/webhooks/product-update.js export default { PRODUCTS_UPDATE: { deliveryMethod: DeliveryMethod.Http, callbackUrl: '/api/webhooks', callback: async (topic, shop, body) => { // Handle webhook } } }
Register in Shopify admin
Test using
npm run dev:webhook
4. Database Operations
Default SQLite setup:
js
// web/server/database/database.js
import { SQLiteSessionStorage } from '@shopify/shopify-app-session-storage-sqlite'
export const sessionStorage = new SQLiteSessionStorage(DB_PATH)
Configuration
Environment Variables
Development:
- Created automatically by
dev:reset
- Stored in
.env
Production:
- Required variables:
SHOPIFY_API_KEY= SHOPIFY_API_SECRET= SCOPES= HOST=
App Bridge Configuration
js
// web/client/src/plugins/appBridge.js
export const appBridge = window.shopify
Vite Configuration
js
// web/client/vite.config.js
export default defineConfig({
plugins: [vue()],
server: {
hmr: hmrConfig,
proxy: proxyOptions
}
})
Testing
Unit Tests
bash
npm run test:unit
Webhook Tests
bash
npm run dev:webhook
Common Tasks
Adding a New Route
Create view component:
vue<!-- web/client/src/views/NewView.vue --> <template> <div> {{ $t('NewView.title') }} </div> </template>
Add route:
js// web/client/src/router/index.js { path: '/new', name: 'new', component: NewView }
Adding an API Endpoint
js
// web/server/routes/new-route.js
import express from 'express'
const router = express.Router()
router.get('/data', async (req, res) => {
// Handle request
})
export default router
Next Steps
After setting up your app:
- Review the Features documentation
- Learn about Internationalization
- Check What's New in Version 3.0
- Read the FAQ for common questions
Getting Help
If you run into issues:
- Check the FAQ
- Search GitHub Issues
- Join our community discussions
- Contact Support for professional assistance