<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Christopher Robin Chase</title>
    <description>The latest articles on DEV Community by Christopher Robin Chase (@chrischase011).</description>
    <link>https://dev.to/chrischase011</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2058592%2F4e30ae67-a716-4f01-b4af-75c3a1cc2425.png</url>
      <title>DEV Community: Christopher Robin Chase</title>
      <link>https://dev.to/chrischase011</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chrischase011"/>
    <language>en</language>
    <item>
      <title>Headless Vue + WordPress Boilerplate v2.0.0</title>
      <dc:creator>Christopher Robin Chase</dc:creator>
      <pubDate>Wed, 07 Oct 2026 01:58:21 +0000</pubDate>
      <link>https://dev.to/chrischase011/headless-vue-wordpress-boilerplate-v200-279i</link>
      <guid>https://dev.to/chrischase011/headless-vue-wordpress-boilerplate-v200-279i</guid>
      <description>&lt;h2&gt;
  
  
  Headless Vue + WordPress Boilerplate v2.0.0
&lt;/h2&gt;

&lt;p&gt;Yes, Version 2.0.0 is here!!!&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 Key Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🌟 Use Vue 3 with Vite for a fast and modern development experience&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;⚡ Hot Module Replacement inside WordPress: save a &lt;code&gt;.vue&lt;/code&gt; file and see it instantly, no rebuild&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🔌 One-line REST API routes in PHP and one-line calls in Vue (&lt;code&gt;useApi&lt;/code&gt;, &lt;code&gt;useWp&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🧭 WordPress pages, posts and menus work out of the box with Vue Router&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🗂 Modular folder structure for components, pages, APIs, and stores&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;⚙️ Supports Vue Router and Pinia (Vue Store)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🎨 Style with Tailwind CSS, standard CSS or your preferred CSS preprocessor&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📋 Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;WordPress 6.7+ and PHP 8.1+&lt;/li&gt;
&lt;li&gt;Node.js 20+&lt;/li&gt;
&lt;li&gt;Pretty permalinks (Settings &amp;gt; Permalinks, anything except "Plain")&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📁 Folder Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;themes/
└── vue-boilerplate/
    ├── functions/               &lt;span class="c"&gt;# WordPress PHP functions&lt;/span&gt;
    │   ├── api.php              &lt;span class="c"&gt;# Your REST API routes&lt;/span&gt;
    │   ├── api-helpers.php      &lt;span class="c"&gt;# vue_theme_api_get(), vue_theme_api_post(), ...&lt;/span&gt;
    │   ├── vite.php             &lt;span class="c"&gt;# Loads the Vue app (dev server or build)&lt;/span&gt;
    │   └── theme-settings.php   &lt;span class="c"&gt;# Theme supports and menu locations&lt;/span&gt;
    ├── src/                     &lt;span class="c"&gt;# Vue application root&lt;/span&gt;
    │   ├── api/                 &lt;span class="c"&gt;# API client (index.js) and JS modules for API calls&lt;/span&gt;
    │   │   └── wp/
    │   ├── assets/              &lt;span class="c"&gt;# Static assets like images and SVGs&lt;/span&gt;
    │   ├── components/          &lt;span class="c"&gt;# Vue components (e.g., layout)&lt;/span&gt;
    │   ├── composables/         &lt;span class="c"&gt;# useApi and useWp&lt;/span&gt;
    │   ├── page/                &lt;span class="c"&gt;# Vue page views&lt;/span&gt;
    │   ├── router/              &lt;span class="c"&gt;# Vue Router setup&lt;/span&gt;
    │   ├── stores/              &lt;span class="c"&gt;# Pinia stores&lt;/span&gt;
    │   │   └── wp/
    │   ├── utils/               &lt;span class="c"&gt;# HTML sanitizer and link helpers&lt;/span&gt;
    │   ├── App.vue              &lt;span class="c"&gt;# Root Vue component&lt;/span&gt;
    │   ├── main.js              &lt;span class="c"&gt;# Vue app entry point&lt;/span&gt;
    │   ├── settings.js          &lt;span class="c"&gt;# Values passed from WordPress&lt;/span&gt;
    │   └── style.css            &lt;span class="c"&gt;# Global styles&lt;/span&gt;
    ├── dist/                    &lt;span class="c"&gt;# Production build (created by npm run build)&lt;/span&gt;
    ├── &lt;span class="k"&gt;*&lt;/span&gt;.php                    &lt;span class="c"&gt;# WordPress theme files (header.php, footer.php, etc.)&lt;/span&gt;
    ├── style.css                &lt;span class="c"&gt;# Theme metadata&lt;/span&gt;
    └── vite.config.js           &lt;span class="c"&gt;# Configuration file for Vite, a fast frontend build tool.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🚀 Getting Started
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download and put the files inside your &lt;code&gt;themes&lt;/code&gt; folder, then activate the theme.&lt;br&gt;
&lt;a href="https://github.com/chrischase011/wordpress-vue-theme-boilerplate/releases" rel="noopener noreferrer"&gt;Download Latest Release&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Dependencies&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Run the Development Server
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;your WordPress site URL&lt;/strong&gt; (e.g. &lt;code&gt;http://mysite.local&lt;/code&gt;), not the Vite URL.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While &lt;code&gt;npm run dev&lt;/code&gt; is running, WordPress loads the app from the Vite dev server. Vue and CSS changes show up instantly, and PHP changes reload the page. Stop the dev server and WordPress goes back to the production build.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make sure WordPress is running locally (e.g., with LocalWP or Laragon) and that the theme is activated.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  📦 Build for Production
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will compile and optimize your Vue app into &lt;code&gt;dist/&lt;/code&gt;. Upload the theme with the &lt;code&gt;dist&lt;/code&gt; folder, you don't need &lt;code&gt;node_modules&lt;/code&gt; or &lt;code&gt;src&lt;/code&gt; on the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔌 Working with the API
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Add a route (PHP)
&lt;/h3&gt;

&lt;p&gt;Add it at the bottom of &lt;code&gt;functions/api.php&lt;/code&gt;. Routes live under &lt;code&gt;/wp-json/vue-theme/v1/&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;vue_theme_api_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/books'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;get_posts&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'post_type'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'book'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// URL parameter&lt;/span&gt;
&lt;span class="nf"&gt;vue_theme_api_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/books/{id}'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_post&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$book&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WP_Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'not_found'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Book not found.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'status'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$book&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// JSON body&lt;/span&gt;
&lt;span class="nf"&gt;vue_theme_api_post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/contact'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sanitize_email&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'email'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'sent'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Logged in users only, or users with a capability&lt;/span&gt;
&lt;span class="nf"&gt;vue_theme_api_post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/notes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'my_callback'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'permission'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="nf"&gt;vue_theme_api_delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/notes/{id}'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'my_callback'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'permission'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'edit_posts'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Use it (Vue)
&lt;/h3&gt;

&lt;p&gt;In a component, &lt;code&gt;useApi&lt;/code&gt; and &lt;code&gt;useWp&lt;/code&gt; are auto-imported and give you reactive state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;books&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useApi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;books&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// WordPress core API: posts, pages, categories, media, your custom post types...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;totalPages&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useWp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;per_page&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;page&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;}))&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;v-if=&lt;/span&gt;&lt;span class="s"&gt;"loading"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Loading...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;v-else-if=&lt;/span&gt;&lt;span class="s"&gt;"error"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;v-else&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;v-for=&lt;/span&gt;&lt;span class="s"&gt;"book in books"&lt;/span&gt; &lt;span class="na"&gt;:key=&lt;/span&gt;&lt;span class="s"&gt;"book.ID"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post_title&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Anywhere else (stores, event handlers), use the clients:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;wp&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/api&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// or a relative path like '../api'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;books&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;books&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;contact&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;wp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;per_page&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;search&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;totalPages&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;wp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;paginate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;page&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Failed requests throw an &lt;code&gt;ApiError&lt;/code&gt; with &lt;code&gt;message&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt; and &lt;code&gt;code&lt;/code&gt;. The nonce for logged in users is sent automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧭 Routing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add your own routes in &lt;code&gt;src/router/index.js&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Any other URL is looked up in WordPress: &lt;code&gt;src/page/Content.vue&lt;/code&gt; shows the page or post with that slug, or a "Page not found" message.&lt;/li&gt;
&lt;li&gt;Menus assigned to &lt;strong&gt;Primary Menu&lt;/strong&gt; and &lt;strong&gt;Footer Menu&lt;/strong&gt; (Appearance &amp;gt; Menus) are rendered by &lt;code&gt;Header.vue&lt;/code&gt; and &lt;code&gt;Footer.vue&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🛠 Integration Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Site title, logo and menus are available without a request: &lt;code&gt;useSiteStore()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pass your own PHP data to Vue with the &lt;code&gt;vue_theme_app_config&lt;/code&gt; filter, then read it from &lt;code&gt;window.wpVueTheme&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always use &lt;code&gt;sanitizeHtml()&lt;/code&gt; from &lt;code&gt;src/utils/html.js&lt;/code&gt; before rendering WordPress content with &lt;code&gt;v-html&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import images from &lt;code&gt;src/assets&lt;/code&gt; so they get the right URL after the build&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set &lt;code&gt;show_in_rest&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; on your custom post types to load them with &lt;code&gt;useWp('your-post-type')&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ❓ Troubleshooting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"The Vue app is not built yet"&lt;/strong&gt;: run &lt;code&gt;npm install&lt;/code&gt; and &lt;code&gt;npm run build&lt;/code&gt;, or start &lt;code&gt;npm run dev&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Changes don't show up&lt;/strong&gt;: check that &lt;code&gt;npm run dev&lt;/code&gt; is still running and that you opened the WordPress URL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Port 5173 is already in use&lt;/strong&gt;: create &lt;code&gt;.env.local&lt;/code&gt; with &lt;code&gt;VITE_DEV_PORT=5174&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local domain is not &lt;code&gt;localhost&lt;/code&gt;, &lt;code&gt;*.local&lt;/code&gt;, &lt;code&gt;*.loc&lt;/code&gt; or &lt;code&gt;*.test&lt;/code&gt;&lt;/strong&gt;: add &lt;code&gt;VITE_WP_ORIGIN=http://your-domain&lt;/code&gt; to &lt;code&gt;.env.local&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WordPress runs in Docker&lt;/strong&gt;: PHP can't see the dev server on your machine, so add &lt;code&gt;add_filter('vue_theme_check_dev_server', '__return_false');&lt;/code&gt; to &lt;code&gt;functions.php&lt;/code&gt; while developing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vue routes return a server 404&lt;/strong&gt;: enable pretty permalinks in Settings &amp;gt; Permalinks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ⬆️ Upgrading from 1.x
&lt;/h2&gt;

&lt;p&gt;See &lt;a href="//CHANGELOG.md"&gt;CHANGELOG.md&lt;/a&gt; for the breaking changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Github Repo
&lt;/h2&gt;

&lt;p&gt;See &lt;a href="https://github.com/chrischase011/wordpress-vue-theme-boilerplate" rel="noopener noreferrer"&gt;Headless Vue + WordPress Boilerplate v2.0.0&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  License
&lt;/h2&gt;

&lt;p&gt;See &lt;a href="https://dev.toLICENSE"&gt;MIT License&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Prepared by: &lt;a href="https://github.com/chrischase011" rel="noopener noreferrer"&gt;Christopher Robin Chase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>javascript</category>
      <category>vue</category>
      <category>wordpress</category>
    </item>
    <item>
      <title>Headless Vue + WordPress Boilerplate</title>
      <dc:creator>Christopher Robin Chase</dc:creator>
      <pubDate>Tue, 15 Apr 2025 08:12:43 +0000</pubDate>
      <link>https://dev.to/chrischase011/headless-vue-wordpress-boilerplate-2je5</link>
      <guid>https://dev.to/chrischase011/headless-vue-wordpress-boilerplate-2je5</guid>
      <description>&lt;h2&gt;
  
  
  Headless Vue + WordPress Boilerplate
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 Key Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🌟 Use Vue 3 with Vite for a fast and modern development experience&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🔌 Connects to WordPress REST API for dynamic content&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🗂 Modular folder structure for components, pages, APIs, and stores&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;♻️ Supports Vue Router and Pinia (Vue Store)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🎨 Style with standard CSS or your preferred CSS preprocessor&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📁 Folder Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;themes/
└── vue-boilerplate/
    ├── functions/               &lt;span class="c"&gt;# WordPress PHP functions&lt;/span&gt;
    ├── public/                  &lt;span class="c"&gt;# Public assets&lt;/span&gt;
    ├── src/                     &lt;span class="c"&gt;# Vue application root&lt;/span&gt;
    │   ├── api/                 &lt;span class="c"&gt;# JS modules for API calls&lt;/span&gt;
    │   │   └── wp/
    │   ├── assets/              &lt;span class="c"&gt;# Static assets like images and SVGs&lt;/span&gt;
    │   ├── components/          &lt;span class="c"&gt;# Vue components (e.g., layout)&lt;/span&gt;
    │   ├── page/                &lt;span class="c"&gt;# Vue page views&lt;/span&gt;
    │   ├── router/              &lt;span class="c"&gt;# Vue Router setup&lt;/span&gt;
    │   └── stores/              &lt;span class="c"&gt;# Pinia stores&lt;/span&gt;
    │       └── wp/
    │   ├─── App.vue             &lt;span class="c"&gt;# Root Vue component&lt;/span&gt;
    │   ├─── main.js             &lt;span class="c"&gt;# Vue app entry point&lt;/span&gt;
    │   └─── style.css           &lt;span class="c"&gt;# Global styles&lt;/span&gt;
    ├── index.html               &lt;span class="c"&gt;# Entry HTML for the Vue app&lt;/span&gt;
    ├── &lt;span class="k"&gt;*&lt;/span&gt;.php                    &lt;span class="c"&gt;# WordPress theme files (header.php, footer.php, etc.)&lt;/span&gt;
    ├── style.css                &lt;span class="c"&gt;# Wordpress Global styles + Theme metadata&lt;/span&gt;
    ├── vite.config.js           &lt;span class="c"&gt;# Configuration file for Vite, a fast frontend build tool.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🚀 Getting Started
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download and put the files inside your &lt;code&gt;themes&lt;/code&gt; folder.&lt;br&gt;
&lt;a href="https://github.com/chrischase011/wordpress-vue-theme-boilerplate/releases" rel="noopener noreferrer"&gt;Download Latest Release&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Dependencies&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Run the Development Server
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will start the Vite development server and compile your Vue frontend.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make sure WordPress is running locally (e.g., with LocalWP or Laragon) and that the theme is activated.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  📦 Build for Production
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will compile and optimize your Vue app for production inside the WordPress theme.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠 Integration Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use the functions.php file to enqueue the compiled assets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use WordPress routes to serve the base HTML (&lt;code&gt;index.php&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect your Vue app to the WP REST API through &lt;code&gt;src/api/wp/&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Feel free to clone or fork the repository and customize it for your projects.&lt;/p&gt;

&lt;p&gt;Contributions and feedback are always welcome! 😃 &lt;/p&gt;

&lt;p&gt;Repository: &lt;a href="https://github.com/chrischase011/wordpress-vue-theme-boilerplate" rel="noopener noreferrer"&gt;https://github.com/chrischase011/wordpress-vue-theme-boilerplate&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Star it if you find it useful! ⭐😉&lt;/p&gt;

&lt;p&gt;Prepared by: &lt;a href="https://github.com/chrischase011" rel="noopener noreferrer"&gt;Christopher Robin Chase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>wordpress</category>
      <category>php</category>
      <category>javascript</category>
    </item>
    <item>
      <title>.bashrc Cheatsheet - Shortcut Commands</title>
      <dc:creator>Christopher Robin Chase</dc:creator>
      <pubDate>Thu, 12 Sep 2024 15:02:05 +0000</pubDate>
      <link>https://dev.to/chrischase011/bashrc-cheatsheet-shortcut-commands-2i60</link>
      <guid>https://dev.to/chrischase011/bashrc-cheatsheet-shortcut-commands-2i60</guid>
      <description>&lt;p&gt;My own &lt;code&gt;.bashrc&lt;/code&gt; file uses aliases that you can use in your development. This file can speed up your development without typing long commands.&lt;/p&gt;

&lt;p&gt;Note: You must have Git Bash, WSL, Linux OS, macOS, or any platform/software that can run a Bash shell (or a compatible shell) to make it work.&lt;/p&gt;

&lt;p&gt;This &lt;code&gt;.bashrc&lt;/code&gt; provides shortcut command for:&lt;/p&gt;

&lt;p&gt;Basic Bash commands&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NPM Core&lt;/li&gt;
&lt;li&gt;Nuxt&lt;/li&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;li&gt;Vite&lt;/li&gt;
&lt;li&gt;Laravel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please visit the Github repository stated below to clone and check the available commands. You can also send a pull request to provide more shortcut commands to this &lt;code&gt;.bashrc&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Github Link: &lt;a href="https://github.com/chrischase011/bashrc-cheatsheet" rel="noopener noreferrer"&gt;https://github.com/chrischase011/bashrc-cheatsheet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Prepared by: &lt;a href="https://github.com/chrischase011/" rel="noopener noreferrer"&gt;Christopher Robin Chase&lt;/a&gt; - Software Engineer&lt;/p&gt;

</description>
      <category>bash</category>
      <category>vscode</category>
      <category>gitbash</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Termux-Ngrok Configuration</title>
      <dc:creator>Christopher Robin Chase</dc:creator>
      <pubDate>Wed, 11 Sep 2024 13:57:47 +0000</pubDate>
      <link>https://dev.to/chrischase011/termux-ngrok-configuration-20ho</link>
      <guid>https://dev.to/chrischase011/termux-ngrok-configuration-20ho</guid>
      <description>&lt;h2&gt;
  
  
  Procedures to configure ngrok on termux to run nginx webserver
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Steps to Configure Nginx on Termux with Ngrok&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download Termux at Playstore&lt;/li&gt;
&lt;li&gt;Open Termux app after download&lt;/li&gt;
&lt;li&gt;Update apt-get or pkg using this command  you can use apt-get or pkg in installing package
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;apt-get update
pkg upgrade
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Access shared and external storage using this command
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;termux-setup-storage
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then navigate to the home directory to check if the internal storage folder is present.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;  cd ~
  ls
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the &lt;code&gt;storage&lt;/code&gt; folder is in the list, then you're good to go.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install nginx
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;pkg install nginx
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;After installing Nginx, you can access localhost using your phone's browser. Just type: &lt;code&gt;localhost:8080&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the Nginx welcome page appears, then the installation was successful.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: You can also stop the Nginx service by typing the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;  nginx -s stop
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The default location for Nginx HTML files is &lt;code&gt;/usr/share/nginx/html&lt;/code&gt;. You can use the following command to navigate to that directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;cd ~
cd ..
cd /usr/share/nginx/html
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To view the contents of the folder, type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;ls
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This is where you deploy HTML files to run on the Nginx web server. You’ll find the default Nginx web page named &lt;code&gt;index.html&lt;/code&gt; in this directory.&lt;/p&gt;

&lt;p&gt;8.1 If you want to configure the Nginx &lt;code&gt;.conf&lt;/code&gt; file (for example, to change the port), you can navigate to &lt;code&gt;/etc/nginx&lt;/code&gt; to locate the &lt;code&gt;nginx.conf file&lt;/code&gt;. To do so, type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;cd ~
cd ..
cd /usr/etc/nginx
ls
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, you can find the nginx.conf file there. To view its contents, type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;cat nginx.conf
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to edit the file, make sure to install the &lt;code&gt;nano&lt;/code&gt; package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;pkg install nano
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installing nano, you can now edit the file using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;nano nginx.conf
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: locate the&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;server {

&lt;/span&gt;&lt;span class="gp"&gt;   listen     8080;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;   server_name    localhost;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To edit the port from 8080 to your choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: Editing this file can disrupt the &lt;code&gt;web server service&lt;/code&gt;, so be careful when modifying the &lt;code&gt;conf&lt;/code&gt; file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To access localhost on a different device, we will use &lt;code&gt;ngrok&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Ngrok&lt;/code&gt; is a cross-platform application that exposes local server ports to the internet.&lt;/p&gt;

&lt;p&gt;To get started, download &lt;code&gt;ngrok&lt;/code&gt; from: &lt;a href="https://ngrok.com/download" rel="noopener noreferrer"&gt;https://ngrok.com/download&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Register on the &lt;code&gt;ngrok&lt;/code&gt; website, as we will use your own &lt;code&gt;Auth Token&lt;/code&gt; to save it on Termux and enable at least the free plan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Make sure that the &lt;code&gt;ngrok&lt;/code&gt; zip file is in the &lt;code&gt;Download&lt;/code&gt; folder of your internal storage so that it can be easily accessed from Termux.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After installing &lt;code&gt;ngrok&lt;/code&gt;, navigate to the "Download" folder in your internal storage.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;cd ~
cd storage
ls   // to check if the download folder exists

cd download
ls // to check the ngrok zip file
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, type the following command to unzip the file and extract it to the home directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;unzip ngrok.zip -d ~
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The file name of ngrok may differ, so you need to type the exact filename of the zip file in order to unzip it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After you unzipped the file, lets go to home folder.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;cd ~ 
ls
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;If you see ngrok in the list, then it's good.
Next, let's change its permissions to make it executable. Type the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;chmod +x ngrok
ls
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If ngrok is now displayed in green, it is ready to be launched.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now, it's time to log in to the ngrok website and copy your &lt;code&gt;auth_token&lt;/code&gt; to Termux.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the dashboard, you will find the command to save your &lt;code&gt;token&lt;/code&gt; in Termux. To do this, type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;./ngrok &amp;lt;auth_token&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;./ngrok 3yfi69Hf9ekfpsh&amp;amp;dhjPsnfu&amp;amp;dhdoapBs7znao7adn
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure you see a success message or at least "Auth Saved" after doing this.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now, let's try to connect our localhost to ngrok. We know that it uses port &lt;code&gt;8080&lt;/code&gt;. To do so, type the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;./ngrok http 8080
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, &lt;code&gt;Termux&lt;/code&gt; will switch to the ngrok connection service, where you can see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;ngrok by @inconshreveable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Version&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Status&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Region, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, let's look at the Session Status. It will always say "Reconnecting" and loop indefinitely. This happens because the latest version of ngrok may not work directly in Termux as it requires &lt;code&gt;/etc/resolv.conf&lt;/code&gt;. To resolve this, let's install another package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;pkg install proot
pkg install proot resolve-conf
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note (Important)&lt;/strong&gt;: After installing proot, every time you use &lt;code&gt;ngrok&lt;/code&gt;, you must run this command to use &lt;code&gt;ngrok&lt;/code&gt; properly each time you close Termux.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;termux-chroot
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;termux-chroot&lt;/code&gt; gives ngrok access to start a tunneling service, allowing us to expose our localhost to the internet.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After that, you are now ready to use &lt;code&gt;ngrok&lt;/code&gt; anytime, anywhere, as long as you have an internet connection. Type this command again:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;ngrok http 8080
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the Session Status will turn green and say "online." You will see two Forwarding links, one for HTTP and one for HTTPS. We will use the HTTP link to browse it in your browser.&lt;/p&gt;

&lt;p&gt;Now, let's open it in your browser. Just copy the HTTP domain and paste it into the search bar.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://4488-136-158-8-66.ngrok.io&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And you will see the &lt;code&gt;Welcome to Nginx page&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;To deploy web files, always refer to procedure number 8.&lt;/p&gt;

&lt;p&gt;The default location for Nginx HTML files is &lt;code&gt;/usr/share/nginx/html&lt;/code&gt;. You can use the following command to navigate to that directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;cd ~
cd ..
cd /usr/share/nginx/html
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And always remember to type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;   termux-chroot
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everytime we open termux app to run ngrok.&lt;/p&gt;

&lt;p&gt;That's all thank you.&lt;/p&gt;

&lt;p&gt;Prepared by &lt;a href="https://github.com/chrischase011" rel="noopener noreferrer"&gt;Christopher Robin Chase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>linux</category>
      <category>termux</category>
    </item>
  </channel>
</rss>
