<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Deependra's Dev Journal]]></title><description><![CDATA[Explore practical tutorials, coding tips and real-world projects on SharePoint, SPFx, React, TypeScript, Microsoft 365, Power Platform and modern development.]]></description><link>https://deependrasdevjournal.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6429dd4f0e7e08e3bf187271/2b3a828e-207e-4a4f-af99-c0440f970fd6.png</url><title>Deependra&apos;s Dev Journal</title><link>https://deependrasdevjournal.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Fri, 20 Nov 2026 20:03:26 GMT</lastBuildDate><atom:link href="https://deependrasdevjournal.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[# ⚔️ SharePoint REST API vs PnPjs: Which One Should You Use in SPFx?]]></title><description><![CDATA[Compare SharePoint REST API and PnPjs in SPFx with practical TypeScript examples, CRUD operations, advantages and real-world use cases.]]></description><link>https://deependrasdevjournal.hashnode.dev/sharepoint-rest-api-vs-pnpjs-which-one-should-you-use-in-spfx</link><guid isPermaLink="true">https://deependrasdevjournal.hashnode.dev/sharepoint-rest-api-vs-pnpjs-which-one-should-you-use-in-spfx</guid><category><![CDATA[SharePoint]]></category><category><![CDATA[PnP]]></category><category><![CDATA[REST API]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[React]]></category><category><![CDATA[sPfx]]></category><dc:creator><![CDATA[Deependra Singh]]></dc:creator><pubDate>Thu, 12 Nov 2026 11:11:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6429dd4f0e7e08e3bf187271/d248d4c1-c325-4562-894f-0761dc49f1e8.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Understanding the differences between SharePoint REST API and PnPjs with practical TypeScript examples.</em></p>
<hr />
<h2>👋 Introduction</h2>
<p>If you've worked with SharePoint Framework (SPFx), you've probably come across two popular ways of communicating with SharePoint data:</p>
<ul>
<li>SharePoint REST API</li>
<li>PnPjs (Patterns and Practices JavaScript Library)</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6429dd4f0e7e08e3bf187271/dff07666-f24c-49ea-b0ad-2da0550c6a54.gif" alt="" style="display:block;margin:0 auto" />

<p>Both approaches allow developers to interact with SharePoint lists, libraries, sites and other resources.</p>
<p>But here's a question I often think about:</p>
<p><strong>If both can perform the same operations, why should we use PnPjs when we can directly call SharePoint REST APIs?</strong></p>
<p>Let's understand the differences with practical examples.</p>
<h2>🔍 1. What is SharePoint REST API?</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6429dd4f0e7e08e3bf187271/bc004da2-6335-4fdf-a22c-851ac1b65142.png" alt="" style="display:block;margin:0 auto" />

<p>SharePoint REST API allows developers to interact with SharePoint resources using HTTP requests.</p>
<p>You can perform CRUD operations:</p>
<ul>
<li>🟢 Create items</li>
<li>🔵 Read items</li>
<li>🟡 Update items</li>
<li>🔴 Delete items</li>
</ul>
<p>SharePoint exposes REST endpoints using the <code>/_api/</code> path.</p>
<p>For example, to retrieve items from a SharePoint list:</p>
<pre><code class="language-http">GET https://yourtenant.sharepoint.com/sites/dev/_api/web/lists/getbytitle('Employees')/items
</code></pre>
<p>You can use standard HTTP methods and OData query options such as <code>$select</code>, <code>$filter</code>, <code>$expand</code> and <code>$orderby</code>.</p>
<h3>Example: Fetch list items using REST API</h3>
<p>In SPFx, we can use the built-in <code>SPHttpClient</code> to make SharePoint REST requests.</p>
<pre><code class="language-typescript">import { SPHttpClient } from '@microsoft/sp-http';

const webUrl = this.context.pageContext.web.absoluteUrl;

const endpoint =
  `${webUrl}/_api/web/lists/getbytitle('Employees')/items` +
  `?$select=Id,Title,Department`;

const response = await this.context.spHttpClient.get(
  endpoint,
  SPHttpClient.configurations.v1,
  {
    headers: {
      Accept: 'application/json;odata=nometadata'
    }
  }
);

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const result = await response.json();

console.log(result.value);
</code></pre>
<p>That's it! We're directly communicating with the SharePoint REST endpoint.</p>
<h2>🧩 2. What is PnPjs?</h2>
<p>PnPjs is an open-source JavaScript and TypeScript library developed by the SharePoint Patterns and Practices community.</p>
<p>It provides a fluent API for working with SharePoint and Microsoft 365 REST APIs.</p>
<p>Instead of manually constructing HTTP requests, headers and endpoint URLs for every operation, PnPjs provides a cleaner and more developer-friendly approach.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6429dd4f0e7e08e3bf187271/c434bbd4-51c5-4dea-a595-daf0cbc19219.png" alt="" style="display:block;margin:0 auto" />

<p>Some useful features include:</p>
<ul>
<li>✨ Fluent API syntax</li>
<li>🔐 SPFx context integration</li>
<li>📦 TypeScript-friendly development</li>
<li>⚡ Request batching</li>
<li>🚀 Caching capabilities</li>
<li>🔗 SharePoint and Microsoft Graph integrations</li>
</ul>
<h3>Example: Fetch list items using PnPjs</h3>
<p>First, install the package:</p>
<pre><code class="language-bash">npm install @pnp/sp
</code></pre>
<p>Then configure PnPjs with your SPFx context.</p>
<p>Create a file called <code>PnPConfig.ts</code>:</p>
<pre><code class="language-typescript">import { SPFI, spfi } from "@pnp/sp";
import { SPFx } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";

let sp: SPFI;

export const initializePnP = (context: any): void =&gt; {
  sp = spfi().using(SPFx(context));
};

export const getSP = (): SPFI =&gt; {
  if (!sp) {
    throw new Error("PnPjs has not been initialized");
  }

  return sp;
};
</code></pre>
<p>Initialize it in your SPFx web part:</p>
<pre><code class="language-typescript">import { initializePnP } from "./PnPConfig";

public async onInit(): Promise&lt;void&gt; {
  await super.onInit();

  initializePnP(this.context);
}
</code></pre>
<p>Now let's retrieve the same list items:</p>
<pre><code class="language-typescript">import { getSP } from "./PnPConfig";

const items = await getSP()
  .web
  .lists
  .getByTitle("Employees")
  .items
  .select("Id", "Title", "Department")();

console.log(items);
</code></pre>
<p>Notice the difference?</p>
<p>We don't need to manually construct the REST endpoint or parse the response using <code>response.json()</code>.</p>
<p>PnPjs provides a fluent interface that makes the code easier to read and maintain.</p>
<h2>⚖️ 3. REST API vs PnPjs: Side-by-Side Comparison</h2>
<table>
<thead>
<tr>
<th>Feature</th>
<th>SharePoint REST</th>
<th>PnPjs</th>
</tr>
</thead>
<tbody><tr>
<td>Approach</td>
<td>Direct HTTP requests</td>
<td>Fluent library API</td>
</tr>
<tr>
<td>Syntax</td>
<td>Endpoint + HTTP methods</td>
<td>Method chaining</td>
</tr>
<tr>
<td>Configuration</td>
<td>Request and headers</td>
<td>Library configuration</td>
</tr>
<tr>
<td>TypeScript</td>
<td>Manual typing often needed</td>
<td>Type-friendly API</td>
</tr>
<tr>
<td>CRUD operations</td>
<td>Supported</td>
<td>Supported</td>
</tr>
<tr>
<td>Filtering</td>
<td>OData query strings</td>
<td>Fluent query methods</td>
</tr>
<tr>
<td>Batching</td>
<td>REST batch requests</td>
<td>Batch helpers</td>
</tr>
<tr>
<td>Dependencies</td>
<td>SPFx HTTP client</td>
<td>Additional packages</td>
</tr>
<tr>
<td>Flexibility</td>
<td>Direct endpoint control</td>
<td>Convenient abstractions</td>
</tr>
</tbody></table>
<p><strong>Important:</strong> PnPjs is not a separate SharePoint API. It is a library that helps developers consume SharePoint and Microsoft 365 APIs.</p>
<p>Under the hood, PnPjs uses REST requests for its SharePoint operations.</p>
<h2>💻 4. Let's Compare a Few More Operations</h2>
<p>Let's look at how the syntax differs when performing everyday SharePoint operations.</p>
<h3>A. Retrieve items with filtering</h3>
<p><strong>REST API</strong></p>
<pre><code class="language-http">GET /_api/web/lists/getbytitle('Employees')/items?$filter=Department eq 'IT'
</code></pre>
<p><strong>PnPjs</strong></p>
<pre><code class="language-typescript">const items = await getSP()
  .web
  .lists
  .getByTitle("Employees")
  .items
  .filter("Department eq 'IT'")();
</code></pre>
<h3>B. Create a new list item</h3>
<p><strong>REST API</strong></p>
<pre><code class="language-typescript">const endpoint =
  `${webUrl}/_api/web/lists/getbytitle('Employees')/items`;

const response = await this.context.spHttpClient.post(
  endpoint,
  SPHttpClient.configurations.v1,
  {
    headers: {
      Accept: "application/json;odata=nometadata",
      "Content-Type": "application/json;odata=nometadata"
    },
    body: JSON.stringify({
      Title: "John",
      Department: "IT"
    })
  }
);
</code></pre>
<p><strong>PnPjs</strong></p>
<pre><code class="language-typescript">const result = await getSP()
  .web
  .lists
  .getByTitle("Employees")
  .items
  .add({
    Title: "John",
    Department: "IT"
  });
</code></pre>
<h3>C. Update an existing item</h3>
<p><strong>PnPjs</strong></p>
<pre><code class="language-typescript">await getSP()
  .web
  .lists
  .getByTitle("Employees")
  .items
  .getById(1)
  .update({
    Title: "John Updated"
  });
</code></pre>
<h3>D. Delete an item</h3>
<p><strong>PnPjs</strong></p>
<pre><code class="language-typescript">await getSP()
  .web
  .lists
  .getByTitle("Employees")
  .items
  .getById(1)
  .delete();
</code></pre>
<p>For REST API, you would send the appropriate HTTP request to the specific item endpoint with the required headers and request configuration.</p>
<h2>🤔 5. Which One Should You Choose?</h2>
<p>This is where things get interesting.</p>
<p>There isn't one universal answer. It depends on your project requirements.</p>
<h3>Choose SharePoint REST API when:</h3>
<ul>
<li>You need direct control over HTTP requests.</li>
<li>You're working with a specific REST endpoint.</li>
<li>You want to avoid an additional library dependency.</li>
<li>You're integrating SharePoint with applications outside SPFx.</li>
<li>You need to understand exactly what request is being sent.</li>
</ul>
<h3>Choose PnPjs when:</h3>
<ul>
<li>You're developing SPFx web parts or extensions.</li>
<li>You frequently perform CRUD operations.</li>
<li>You want cleaner and more readable TypeScript code.</li>
<li>You're working with multiple SharePoint lists.</li>
<li>You want to use fluent queries, batching and caching features.</li>
</ul>
<h2>🚀 6. My Take as an SPFx Developer</h2>
<p>When working on SharePoint solutions, I find that code readability and maintainability become increasingly important as projects grow.</p>
<p>Imagine working with multiple lists, attachments, user information, lookup fields and complex filtering conditions.</p>
<p>Writing every request manually can make your service layer lengthy and repetitive.</p>
<p>PnPjs provides a convenient abstraction for these operations.</p>
<p>However, I wouldn't say that REST API is outdated or that developers should stop learning it.</p>
<p><strong>Understanding SharePoint REST API is important even when you're using PnPjs.</strong></p>
<p>Why?</p>
<p>Because knowing what's happening behind the scenes helps you troubleshoot errors, understand OData queries, optimize requests and debug complex SharePoint operations.</p>
<p>My recommendation:</p>
<ul>
<li>Learn SharePoint REST API fundamentals first.</li>
<li>Use PnPjs to simplify common SPFx development tasks.</li>
<li>Understand both approaches so you can choose the right one for each scenario.</li>
</ul>
<h2>🎯 Conclusion</h2>
<p>SharePoint REST API and PnPjs are both valuable tools in the SharePoint development ecosystem.</p>
<p>REST API gives you direct access and control over HTTP requests, while PnPjs provides a fluent and convenient way to interact with SharePoint and Microsoft 365.</p>
<p>Rather than treating them as competitors, understand how they complement each other.</p>
<p><strong>Learn the API. Understand the abstraction. Write better code. 🚀</strong></p>
<hr />
<h2>📚 Useful Resources</h2>
<ul>
<li><a href="https://learn.microsoft.com/en-us/sharepoint/dev/spfx/connect-to-sharepoint">Microsoft Learn – Connect to SharePoint APIs in SPFx</a></li>
<li><a href="https://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/use-sp-pnp-js-with-spfx-web-parts">Microsoft Learn – Use PnPjs with SPFx</a></li>
<li><a href="https://pnp.github.io/pnpjs/">PnPjs Official Documentation</a></li>
<li><a href="https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service">SharePoint REST API Documentation</a></li>
</ul>
<hr />
<p>💬 <strong>What do you prefer in your SPFx projects: SharePoint REST API or PnPjs?</strong></p>
<p>Share your experience in the comments. I'd love to hear how other developers approach this!</p>
]]></content:encoded></item><item><title><![CDATA[🚀 I Built a CLI to Create SPFx Projects with Tailwind CSS Pre-Configured!]]></title><description><![CDATA[Learn how to simplify SharePoint Framework development using a CLI that creates projects with Tailwind CSS pre-configured.]]></description><link>https://deependrasdevjournal.hashnode.dev/i-built-a-cli-to-create-spfx-projects-with-tailwind-css-pre-configured</link><guid isPermaLink="true">https://deependrasdevjournal.hashnode.dev/i-built-a-cli-to-create-spfx-projects-with-tailwind-css-pre-configured</guid><category><![CDATA[SharePoint]]></category><category><![CDATA[SharePointFramework]]></category><category><![CDATA[sPfx]]></category><category><![CDATA[SharePoint development services]]></category><category><![CDATA[sharepoint cli]]></category><dc:creator><![CDATA[Deependra Singh]]></dc:creator><pubDate>Wed, 11 Nov 2026 13:58:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6429dd4f0e7e08e3bf187271/d89fdbd4-aeac-428d-a50b-12b896a86f27.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<h2>👋 Introduction</h2>
<p>If you've worked with <strong>SharePoint Framework (SPFx)</strong>, you probably know that setting up a new project and configuring your preferred styling tools can take some extra time.</p>
<p>I personally enjoy working with <strong>Tailwind CSS</strong> because it makes styling React components faster, cleaner and more consistent.</p>
<p>But I wanted to make the initial setup easier.</p>
<p>So, I decided to build something of my own: <strong>a CLI tool that helps developers create SPFx projects with Tailwind CSS pre-configured!</strong> 🎉</p>
<p>In this article, I'll walk you through the idea, installation process and how to get started.</p>
<h2>🤔 Why Did I Build This?</h2>
<p>Every time we start a new project, we often repeat similar configuration steps.</p>
<p>For developers who prefer Tailwind CSS, this can mean:</p>
<ul>
<li>Installing and configuring dependencies.</li>
<li>Setting up Tailwind CSS.</li>
<li>Configuring the build environment.</li>
<li>Making sure everything works with SPFx.</li>
<li>Repeating these steps for every new project.</li>
</ul>
<p>I wanted to reduce this repetitive work.</p>
<p><strong>The idea was simple:</strong></p>
<blockquote>
<p>⚡ One command. A ready-to-use SPFx project. Less time configuring, more time building!</p>
</blockquote>
<h2>🛠️ Introducing <code>create-spfx-tailwind-app</code></h2>
<p>Meet my CLI tool:</p>
<p><strong>create-spfx-tailwind-app</strong></p>
<p>It helps developers create SPFx projects with Tailwind CSS pre-configured.</p>
<p>Instead of starting with a blank project and repeating the styling configuration, you can get started using a single command.</p>
<h2>🚀 Getting Started</h2>
<h3>Step 1: Create your project</h3>
<p>Open your terminal and run:</p>
<pre><code class="language-bash">npx create-spfx-tailwind-app MyProject
</code></pre>
<p>That's it! Your project creation process begins.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6429dd4f0e7e08e3bf187271/5e2f61aa-b017-47ac-8a71-b4f3417e7ef6.gif" alt="" style="display:block;margin:0 auto" />

<h3>Step 2: Navigate to your project</h3>
<p>Once the project has been generated:</p>
<pre><code class="language-bash">cd MyProject
</code></pre>
<p>Follow the installation instructions provided by the generated project to install dependencies.</p>
<h3>Step 3: Start exploring!</h3>
<p>Open the project in your preferred code editor and explore the generated structure.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6429dd4f0e7e08e3bf187271/c2204420-4766-4620-8ef4-c3abac7d7bc7.png" alt="" style="display:block;margin:0 auto" />

<h2>🎨 Why Tailwind CSS with SPFx?</h2>
<p>Tailwind CSS follows a utility-first approach to styling.</p>
<p>Here are some reasons I like using it:</p>
<table>
<thead>
<tr>
<th>Benefit</th>
<th>Why it matters</th>
</tr>
</thead>
<tbody><tr>
<td>⚡ Faster development</td>
<td>Style components using utility classes</td>
</tr>
<tr>
<td>🎯 Consistency</td>
<td>Maintain a consistent design system</td>
</tr>
<tr>
<td>📱 Responsive UI</td>
<td>Build responsive layouts easily</td>
</tr>
<tr>
<td>🧩 Reusability</td>
<td>Create reusable React components</td>
</tr>
<tr>
<td>🧹 Less custom CSS</td>
<td>Reduce the need for separate CSS rules</td>
</tr>
</tbody></table>
<p>For example, instead of writing separate CSS rules:</p>
<pre><code class="language-css">.card {
  padding: 20px;
  background-color: #ffffff;
  border-radius: 12px;
}
</code></pre>
<p>You can use Tailwind utility classes directly in JSX:</p>
<pre><code class="language-tsx">&lt;div className="rounded-xl bg-white p-5 shadow-md"&gt;
  &lt;h2 className="text-xl font-bold text-gray-800"&gt;
    Hello SharePoint!
  &lt;/h2&gt;
&lt;/div&gt;
</code></pre>
<p>Simple, readable and convenient! ✨</p>
<h2>👨‍💻 Who Can Benefit From This?</h2>
<p>This CLI can be useful for:</p>
<ul>
<li>SPFx developers who prefer Tailwind CSS.</li>
<li>React developers building SharePoint solutions.</li>
<li>Developers starting new SPFx projects.</li>
<li>Developers who want to simplify repetitive setup tasks.</li>
</ul>
<h2>🔮 What's Next?</h2>
<p>This is just the beginning!</p>
<p>I want to continue improving the CLI, make the setup experience smoother and explore more ways to simplify SPFx development.</p>
<p>I'm also interested in hearing feedback from other developers.</p>
<p>If you try it, let me know what you think!</p>
<h2>🤝 Let's Connect!</h2>
<p>If you're working with SharePoint, SPFx, React or Microsoft 365, I'd love to connect with you.</p>
<p>You can explore my work and follow my development journey here:</p>
<ul>
<li>GitHub: <a href="https://github.com/deependrasingh002/create-spfx-tailwind-app.git">https://github.com/deependrasingh002/create-spfx-tailwind-app.git</a></li>
<li>LinkedIn: <a href="https://www.linkedin.com/in/deependrasingh/">Connect with me</a></li>
</ul>
<h2>🎯 Final Thoughts</h2>
<p>This project started with a simple thought: why spend time repeating configuration steps when we can automate them?</p>
<p>Building this CLI gave me an opportunity to explore developer tooling and make something that could help other developers.</p>
<p><strong>Keep learning. Keep building. Keep sharing! 🚀</strong></p>
<p>Thanks for reading! ❤️</p>
<p>If you found this useful, consider leaving a comment or sharing your feedback.</p>
<hr />
<h1>Tags</h1>
<p><code>sharepoint</code> <code>spfx</code> <code>tailwindcss</code> <code>typescript</code> <code>opensource</code></p>
]]></content:encoded></item></channel></rss>