π©βπ» 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**
π 2. Scaffold a New Project
mkdir spfx-helloworld
cd spfx-helloworld
yo @microsoft/sharepoint
π 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**
π 4. Hello World in React
src/webparts/helloWorld/components/HelloWorld.tsx
import * as React from "react";
export default function HelloWorld(): JSX.Element {
  return (
    <div style={{ padding: 20, fontSize: 20 }}>
      π Hello, SPFx + React World!
    </div>
  );
}
π¨ 5. Add Some Style
npm install @fluentui/react
import { PrimaryButton } from "@fluentui/react";
export default function HelloWorld() {
  return (
    <div>
      <h2>Welcome to SPFx + Fluent UI</h2>
      <PrimaryButton text="Click Me π" />
    </div>
  );
}
Congrats π youβve just unlocked the power of SPFx. Keep experimenting and building.
 
 
              




 
    
Top comments (0)