<?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: Vasim Shaikh</title>
    <description>The latest articles on DEV Community by Vasim Shaikh (@vasim_shaikh_51ae036d02e2).</description>
    <link>https://dev.to/vasim_shaikh_51ae036d02e2</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1809002%2F3f657078-f580-4845-8af1-54af7a0386e3.jpg</url>
      <title>DEV Community: Vasim Shaikh</title>
      <link>https://dev.to/vasim_shaikh_51ae036d02e2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vasim_shaikh_51ae036d02e2"/>
    <language>en</language>
    <item>
      <title>Headless WordPress with React Js : Environment Setup - Session : 1</title>
      <dc:creator>Vasim Shaikh</dc:creator>
      <pubDate>Sat, 20 Jul 2024 15:23:02 +0000</pubDate>
      <link>https://dev.to/vasim_shaikh_51ae036d02e2/headless-wordpress-with-react-js-environment-setup-session-1-40d0</link>
      <guid>https://dev.to/vasim_shaikh_51ae036d02e2/headless-wordpress-with-react-js-environment-setup-session-1-40d0</guid>
      <description>&lt;p&gt;A &lt;strong&gt;Headless CMS&lt;/strong&gt; (Content Management System) is a backend-only content management system that acts primarily as a content repository. A headless CMS allows for the creation, management, and storage of content without a built-in front-end. The content is accessible via an API (Application Programming Interface), enabling developers to build the front-end separately using technologies of their choice, such as React, Angular, or Vue.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup Headless CMS
&lt;/h2&gt;

&lt;p&gt;To set up a headless CMS with WordPress and React, follow these steps:&lt;/p&gt;

&lt;h3&gt;
  
  
  Create the Main Folder
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a Folder:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Name the folder &lt;code&gt;wp-headless&lt;/code&gt;. This folder will contain both WordPress (backend) and the React application (frontend).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3uz65fcyzu206ye6ze5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn3uz65fcyzu206ye6ze5.png" alt="Primary Folders" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  WordPress Backend Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Setup WordPress:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inside the &lt;code&gt;wp-headless&lt;/code&gt; folder, create a folder named &lt;code&gt;Wordpress&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Download and install WordPress following the famous 5-minute installation process.&lt;/li&gt;
&lt;li&gt;After setup, your WordPress installation should be located inside &lt;code&gt;wp-headless/Wordpress&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Remove Inactive Plugins and Themes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log in to the WordPress admin dashboard.&lt;/li&gt;
&lt;li&gt;Navigate to Plugins &amp;gt; Installed Plugins and deactivate/delete any inactive plugins.&lt;/li&gt;
&lt;li&gt;Navigate to Appearance &amp;gt; Themes and delete any inactive themes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Verify API:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure that your WordPress REST API is functioning correctly by visiting &lt;code&gt;http://your-site-url/wp-json/wp/v2&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;This endpoint should display a JSON response with the default WordPress API endpoints.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfz1rz7t52ywl8rblg41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfz1rz7t52ywl8rblg41.png" alt="WP REST API" width="800" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  React Frontend Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install Node.js:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download and install Node.js from &lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;nodejs.org&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Verify the installation by running the following command in your Command Prompt (CMD):
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; node &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;This command should return the Node.js version, confirming the successful installation.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create React App:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React will manage the frontend of your application. To set up a new React app, run the following commands:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; npx create-react-app frontend
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;This command will create a new React application inside a folder named &lt;code&gt;frontend&lt;/code&gt; with a default &lt;code&gt;package.json&lt;/code&gt; file.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Start the React App:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate into the &lt;code&gt;frontend&lt;/code&gt; directory and start the development server:
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;frontend
 npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The above commands will change the directory to &lt;code&gt;frontend&lt;/code&gt; and start the React development server. Your default browser should automatically open and display the React app.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8g768k5xyszhenuue90d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8g768k5xyszhenuue90d.png" alt="React Application" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Setting up a headless CMS using WordPress as the backend and React as the frontend provides a flexible and modern approach to web development. This setup decouples content management from content presentation, allowing developers to leverage the powerful WordPress CMS while using modern JavaScript frameworks for the front-end. This guide walks you through the basic steps to get started with a headless WordPress and React application, laying the foundation for a scalable and maintainable web application.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>woocommerce</category>
      <category>react</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
