Headless Vue + WordPress Boilerplate
This boilerplate allows you to use Vue as the front-end for your WordPress theme in a headless architecture. WordPress handles the backend and REST API, while Vue powers the user interface using modern frontend tooling like Vite.
π§ Key Features
π Use Vue 3 with Vite for a fast and modern development experience
π Connects to WordPress REST API for dynamic content
π Modular folder structure for components, pages, APIs, and stores
β»οΈ Supports Vue Router and Pinia (Vue Store)
π¨ Style with standard CSS or your preferred CSS preprocessor
π Folder Structure
themes/
βββ vue-boilerplate/
βββ functions/ # WordPress PHP functions
βββ public/ # Public assets
βββ src/ # Vue application root
β βββ api/ # JS modules for API calls
β β βββ wp/
β βββ assets/ # Static assets like images and SVGs
β βββ components/ # Vue components (e.g., layout)
β βββ page/ # Vue page views
β βββ router/ # Vue Router setup
β βββ stores/ # Pinia stores
β βββ wp/
β ββββ App.vue # Root Vue component
β ββββ main.js # Vue app entry point
β ββββ style.css # Global styles
βββ index.html # Entry HTML for the Vue app
βββ *.php # WordPress theme files (header.php, footer.php, etc.)
βββ style.css # Wordpress Global styles + Theme metadata
βββ vite.config.js # Configuration file for Vite, a fast frontend build tool.
π Getting Started
Download and put the files inside your
themes
folder.
Download Latest ReleaseInstall Dependencies
npm install
- Run the Development Server
npm run start
This will start the Vite development server and compile your Vue frontend.
Make sure WordPress is running locally (e.g., with LocalWP or Laragon) and that the theme is activated.
π¦ Build for Production
npm run build
This will compile and optimize your Vue app for production inside the WordPress theme.
π Integration Tips
Use the functions.php file to enqueue the compiled assets
Use WordPress routes to serve the base HTML (
index.php
)Connect your Vue app to the WP REST API through
src/api/wp/
Feel free to clone or fork the repository and customize it for your projects.
Contributions and feedback are always welcome! π
Repository: https://github.com/chrischase011/wordpress-vue-theme-boilerplate
Star it if you find it useful! βπ
Prepared by: Christopher Robin Chase
Top comments (0)