A modern starter template for building Microsoft Office Add-ins using Next.js, React, and TypeScript. Build powerful add-ins for Word, Excel, PowerPoint, and Outlook with the latest web technologies.
- β‘ Next.js 15 - Latest App Router with React Server Components
- π¨ Tailwind CSS - Utility-first styling out of the box
- π TypeScript - Full type safety
- π HTTPS Ready - Auto-generated SSL certificates for local development
- π§© Office.js Integration - Pre-configured Office JavaScript API
- π± Taskpane & Commands - Both UI patterns included
- π Production Ready - Easy deployment to Vercel, Azure, or any hosting
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- Yarn or npm
- Microsoft Office (Word, Excel, PowerPoint, or Outlook)
- Desktop app (Windows or Mac) OR
- Microsoft 365 (web version)
# Clone this repository
git clone https://github.com/mohit67890/msoffice-addin-nextjs.git
cd msoffice-addin-nextjs
# Install dependencies
yarn installyarn devThis launches a custom HTTPS server on https://localhost:3000.
Note: On first run, you'll be prompted to trust the self-signed SSL certificate. This is required because Office add-ins must be served over HTTPS.
Launch Microsoft Word with the add-in:
yarn odevOr manually sideload using manifest-local.xml:
- Word/Excel/PowerPoint Desktop: Insert β My Add-ins β Upload My Add-in
- Word/Excel Online: Insert β Office Add-ins β Upload My Add-in
βββ public/ # Static assets
βββ src/
β βββ app/
β β βββ globals.css # Global styles
β β βββ (commands)/ # Office ribbon commands
β β β βββ commands/
β β β βββ page.tsx
β β βββ (taskpane)/ # Taskpane UI
β β βββ taskpane/
β β βββ page.tsx
β βββ components/
β β βββ providers.tsx # Context providers
β β βββ ui/ # Reusable UI components
β βββ lib/
β βββ fonts.ts # Font configuration
β βββ utils.ts # Utility functions
βββ manifest.xml # Production manifest
βββ manifest-local.xml # Development manifest
βββ server.ts # Custom HTTPS dev server
βββ next.config.js # Next.js configuration
| Command | Description |
|---|---|
yarn dev |
Start HTTPS development server |
yarn odev |
Start dev server + launch Word |
yarn build |
Build for production |
yarn start |
Start production server |
yarn lint |
Run ESLint |
The Office JavaScript API is available globally. Example usage in your components:
// Check if Office is ready
Office.onReady((info) => {
if (info.host === Office.HostType.Word) {
// Word-specific code
}
});
// Interact with the document
await Word.run(async (context) => {
const body = context.document.body;
body.insertText("Hello from Next.js!", Word.InsertLocation.end);
await context.sync();
});On Mac: Enable Safari Web Inspector for debugging:
# For Word
defaults write com.microsoft.Word OfficeWebAddinDeveloperExtras -bool true
# For Excel
defaults write com.microsoft.Excel OfficeWebAddinDeveloperExtras -bool trueThen use Safari β Develop menu to inspect the add-in.
On Windows: Use Microsoft Edge DevTools or attach Visual Studio Code debugger.
| Issue | Solution |
|---|---|
| Certificate errors | Delete ~/.office-addin-dev-certs and restart yarn dev |
| Add-in not loading | Check that manifest-local.xml URLs match your dev server |
| Office.js undefined | Ensure code runs after Office.onReady() resolves |
Deploy to any hosting platform that supports Next.js:
Vercel (Recommended):
npx vercelAzure Static Web Apps:
# Use Azure CLI or GitHub ActionsEdit manifest.xml and replace all localhost URLs with your production URL:
<SourceLocation DefaultValue="https://your-app.vercel.app/taskpane"/>For your organization:
- Go to Microsoft 365 Admin Center
- Navigate to Settings β Integrated Apps
- Upload your
manifest.xml
For AppSource (Public): Follow the Microsoft Partner Center submission process.
Edit the manifest.xml to target different Office applications:
<!-- For Excel -->
<Hosts>
<Host Name="Workbook"/>
</Hosts>
<!-- For PowerPoint -->
<Hosts>
<Host Name="Presentation"/>
</Hosts>
<!-- For Outlook -->
<Hosts>
<Host Name="Mailbox"/>
</Hosts>Create new routes in src/app/(taskpane)/:
mkdir -p src/app/\(taskpane\)/settings
touch src/app/\(taskpane\)/settings/page.tsx- Office Add-ins Documentation
- Office.js API Reference
- Next.js Documentation
- Fluent UI React - Microsoft's design system (optional)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ using Next.js and Office.js