I Let AI Build My SharePoint Web Part—Here’s What Happened

    Ever wanted to build your own custom SharePoint web part but felt overwhelmed by code? Same. But thanks to a little help from AI, I built a working, fully functional SharePoint Framework (SPFX) web part with zero development experience.

    This post walks you through how I used Cursor, an AI-powered dev tool, to create two working web parts, including a personalized Welcome Web Part and a flexible Custom Button Web Part.

    Web Part Files

    (⚠️ use at your own discretion/risk! - They worked perfectly for me, though 😉)

    🤖 The AI Magic: Meet Cursor

    Cursor is a code editor with an AI assistant baked in. Unlike ChatGPT, Cursor actually executes the code changes for you. You:

    1. Describe what you want (in plain English)

    2. Paste a user story and acceptance criteria

    3. Sit back and watch as it builds your SPFX web part

    It catches its own errors, suggests fixes, and even sets up your folders and dependencies. It feels like magic.


    ✍️ Start with a Clear Prompt

    You’ll get the best results from Cursor by using a clear, structured prompt. I used the Business Analyst method with:

    • A User Story: A short paragraph explaining the purpose of the web part

    • Acceptance Criteria: A checklist of specific functions and settings you want

    Example:

    User Story:

    As a visitor to a SharePoint Online site, I want to see a personalized welcome message that addresses me by name so that I feel acknowledged.

    Acceptance Criteria:

    • [AC1] The web part must be available in the SharePoint web part toolbox with the name 'Welcome'

    • [AC2] A property pane must allow the site owner to enter a custom welcome message containing the placeholder {currentUser}.

    • [AC3] The web part must replace {currentUser} with the current user's display name when the page is viewed.

    • [AC4] If the current user's name cannot be retrieved, the web part must display a fallback message entered by the site owner.

    • [AC5] The site owner must be able to customise the welcome message style using: font colour, font size, bold, and italic settings.

    • [AC6] The site owner must be able to choose a background colour and opacity for the message box.

    • [AC7] The message box must include padding of 8px 15px for visual comfort.

    • [AC8] The web part must display the message immediately on page load, without delay.

    • [AC9] The web part must be responsive, adapting to different screen sizes and page section widths.

    • [AC10] Use latest supported SPFx version for SharePoint Online.

    Feed this into Cursor, and it’ll take it from there.


    🚧 The Build Process (With Cursor)

    Cursor walks you through each step. When it hits an error (e.g., outdated Node.js version), it:

    • Explains what needs to be done

    • Suggests the fix

    • Waits for your approval

    • Executes it automatically

    Once complete, Cursor gives you an SPPKG package file to upload to SharePoint.


    🧪 Testing It in SharePoint

    1. Head to the SharePoint Admin Center > More Features > Apps

    2. Upload your .sppkg file

    3. Enable it for your test site

    4. Add the app via Site Contents > Add an app

    5. Insert it on a modern page and test it out

    Boom—your AI-generated web part is live!


    🎉 What I Built

    Welcome Web Part

    • Greets the current user by name (e.g., "Welcome Dan Carroll")

    • Customizable font, background, and fallback text

    • Responsive and lightweight

    Button v2 Web Part

    • Enhanced version of SharePoint’s native button

    • Custom styling for font, background, padding, and border radius

    • Great for building branded calls-to-action


    🧠 Tips for Prompting AI

    • Be crystal clear in what you want

    • Use user stories and acceptance criteria

    • Include UI requirements (colors, font, padding, etc.)

    • Ask ChatGPT to help generate your specs before pasting into Cursor


    🧠 Final Thoughts

    This experiment proves that AI can build SharePoint Framework web parts—quickly, cleanly, and with no coding background. Tools like Cursor bridge the gap between business users and pro developers.

    So whether you're just experimenting or planning your first production-grade custom web part, this AI approach is worth a try.


    🎥 Watch the Full Build + Demo

    I show every step in the video, including prompt writing, using Cursor, testing in SharePoint, and exploring the final product.