DEV Community

Cover image for Let's Get Started with SharePoint Framework (SPFx) + React πŸš€
Deependra Singh
Deependra Singh

Posted on

Let's Get Started with SharePoint Framework (SPFx) + React πŸš€

πŸ‘©β€πŸ’» Goal: Build your first Hello World web part in SPFx with React.
⚑ Time: ~15 mins
πŸ”§ Tools: Node.js β€’ Yeoman β€’ Gulp β€’ VS Code

πŸ›  1. Environment Setup

πŸ“Œ SPFx requires the right Node.js LTS (currently Node 18 for SPFx 1.18.2).
πŸ‘‰ If you install the wrong version, you’ll see scary gulp errors ❌.



**npm install -g yo gulp @microsoft/generator-sharepoint**
Enter fullscreen mode Exit fullscreen mode

πŸ“‚ 2. Scaffold a New Project

mkdir spfx-helloworld
cd spfx-helloworld
yo @microsoft/sharepoint
Enter fullscreen mode Exit fullscreen mode

πŸ‘€ You’ll get a wizard:

πŸ“¦ Solution Name β†’ spfx-helloworld
🌐 Target β†’ SharePoint Online only
🧩 Component type β†’ WebPart
βš›οΈ Framework β†’ React
🏷 WebPart Name β†’ HelloWorld

▢️ 3. Run the Project

**gulp serve**
Enter fullscreen mode Exit fullscreen mode

πŸ‘‹ 4. Hello World in React

src/webparts/helloWorld/components/HelloWorld.tsx

Enter fullscreen mode Exit fullscreen mode
import * as React from "react";

export default function HelloWorld(): JSX.Element {
  return (
    <div style={{ padding: 20, fontSize: 20 }}>
      πŸ‘‹ Hello, SPFx + React World!
    </div>
  );
}

Enter fullscreen mode Exit fullscreen mode

🎨 5. Add Some Style

npm install @fluentui/react

Enter fullscreen mode Exit fullscreen mode
import { PrimaryButton } from "@fluentui/react";

export default function HelloWorld() {
  return (
    <div>
      <h2>Welcome to SPFx + Fluent UI</h2>
      <PrimaryButton text="Click Me πŸš€" />
    </div>
  );
}

Enter fullscreen mode Exit fullscreen mode

Congrats 🎊 you’ve just unlocked the power of SPFx. Keep experimenting and building.

Top comments (0)