This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /blog/how-to-build-a-react-powerpoint-viewer.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. How to build a React PowerPoint (PPT and PPTX) viewer

Table of contents

    How to build a React PowerPoint (PPT and PPTX) viewer
    TL;DR

    This tutorial shows how to build a React PowerPoint viewer using Nutrient Web SDK, which converts Office documents to PDF directly in the browser without server-side processing. You’ll create a React project with Vite, add the Nutrient dependency, and implement a component to display PPT/PPTX files. The solution offers additional capabilities like text editing, annotations, and signatures without requiring MS Office software or licenses.

    In this blog post, learn how to build a React PowerPoint viewer using Nutrient Web SDK. You’ll open and view PPT or PPTX files directly in your web browser using client-side processing (no server required).

    The image below shows what you’ll be building.

    A PPTX presentation rendered in the browser by a React PowerPoint viewer built with Nutrient Web SDK

    You can check out the demo to see it in action.

    Opening and rendering Office documents in the browser

    Nutrient Web SDK brings support for Word, Excel, and PowerPoint formats to your application, without you or your users needing any MS Office software, MS Office licenses, or third-party open source software. The technology works by converting an Office document to PDF directly in the browser, and the document is then rendered in our JavaScript viewer.

    Unlocking more capabilities with Office-to-PDF conversion

    By converting an Office document to PDF using client-side JavaScript, you have the option to support a rich array of additional Office document functionality, such as:

    • Text editing — Edit text directly in the displayed Office document.
    • Page manipulation — Organize documents by adding, removing, or rearranging pages.
    • Annotations — Boost collaboration by adding text highlights, comments, or stamps.
    • Adding signatures — Draw, type, or upload a signature directly to an Office document.
    Explore Demo

    Requirements to get started

    To get started, you’ll need:

    Setting up a new React project with Vite

    1. To get started, create a new React project using Vite:

      Terminal window
      # Using Yarn
      yarn create vite nutrient-react-example --template react
      # Using npm
      npm create vite@latest nutrient-react-example -- --template react
    2. Change to the created project directory:

      cd nutrient-react-example

    Adding Nutrient to your project

    1. Add the Nutrient dependency:

      Terminal window
      npm i @nutrient-sdk/viewer
    2. The Nutrient Web SDK loads its WebAssembly and supporting files from a local path, so you need to copy them to the public folder. Start by installing the required copy plugin:

      Terminal window
      npm install -D rollup-plugin-copy

    Then, update your Vite configuration (vite.config.ts) to copy the SDK’s asset files during build:

    import { defineConfig } from 'vite';
    import react from '@vitejs/plugin-react';
    import copy from 'rollup-plugin-copy';
    export default defineConfig({
    plugins: [
    copy({
    targets: [
    {
    src:
    'node_modules/@nutrient-sdk/viewer/dist/nutrient-viewer-lib',
    dest: 'public/',
    },
    ],
    hook: 'buildStart',
    }),
    react(),
    ],
    });

    Displaying a PowerPoint document

    1. Add a PowerPoint (PPT, PPTX) document you want to display to the public directory. You can use our demo document as an example.

    2. Now that everything is set up, you’ll render a PDF using the Nutrient SDK.

      Basic usage in App.tsx:

      import { useEffect, useRef } from 'react';
      function App() {
      const containerRef = useRef(null);
      useEffect(() => {
      const container = containerRef.current;
      let cleanup = () => {};
      (async () => {
      const NutrientViewer = (await import('@nutrient-sdk/viewer'))
      .default;
      // Unload any previous instance.
      NutrientViewer.unload(container);
      if (container && NutrientViewer) {
      NutrientViewer.load({
      container,
      document: 'slides.pptx', // Path to your PowerPoint document.
      baseUrl: `${window.location.protocol}//${
      window.location.host
      }/${import.meta.env.PUBLIC_URL ?? ''}`,
      });
      }
      cleanup = () => {
      NutrientViewer.unload(container);
      };
      })();
      return cleanup;
      }, []);
      return (
      <div
      ref={containerRef}
      style={{ height: '100vh', width: '100vw' }}
      />
      );
      }
      export default App;
    3. Start the app and run it in your default browser:

      Terminal window
      # Using Yarn
      yarn dev
      # Using npm
      npm run dev

    A note about fonts

    In client-side web applications for Microsoft Office-to-PDF conversion, Nutrient addresses font licensing constraints through font substitutions, typically replacing unavailable fonts with their equivalents — like Arial with Noto. For precise font matching, you can provide your own fonts, embed them into source files, or designate paths to your .ttf fonts for custom solutions.

    Adding even more capabilities

    Once you’ve deployed your viewer, you can start customizing it to meet your specific requirements or easily add more capabilities. To help you get started, here are some of our most popular React guides:

    Conclusion

    You should now have our React PowerPoint viewer up and running in your web application. If you hit any snags, don’t hesitate to reach out to our Support team for help.

    You can also integrate our React PowerPoint viewer using web frameworks like Angular, Vue.js, and jQuery. To see a list of all web frameworks, start your free trial. Or, launch our demo to see our viewer in action.

    FAQ

    Here are a few frequently asked questions about building a PowerPoint viewer in React.

    Can the React viewer display both PPT and PPTX files?

    Yes. Nutrient Web SDK renders both the legacy PPT format and modern PPTX by converting the file to PDF in the browser, so the same component handles either format.

    Does the React PowerPoint viewer need Microsoft Office or a server?

    No. Conversion and rendering run entirely client-side via WebAssembly — there’s no Microsoft Office installation, no MS Office licenses, and no server-side processing required.

    What can I do beyond viewing the presentation?

    Because the document is converted to PDF, you can also edit text, add or rearrange pages, annotate, redact, and add eSignatures on the rendered file using the same SDK.

    Hulya Masharipov

    Hulya Masharipov

    Technical Writer

    Hulya is a frontend web developer and technical writer who enjoys creating responsive, scalable, and maintainable web experiences. She’s passionate about open source, web accessibility, cybersecurity privacy, and blockchain.

    Explore related topics

    Try for free Add Office viewing to your app