How to install TinyMCE in a project using React or NextJS?

Find out how to install TinyMCE in React or NextJS and fully customize it with plugins to match your projects.
•
Updated on August 14, 2026
•
8 min read
Believemy logo

TinyMCE is one of the most popular rich text editors, if not the most used. It offers a complete editing experience with a whole bunch of customizable options to perfectly adapt to the needs of each project.

In other words, it greatly enhances the user experience by allowing users to fill in their information as if they were using an editor like Google Docs!

Good to know

We also talk about a WYSIWYG editor (what you see is what you get - which translates to "what you see is what you get" in good French 😋).

This means that the elements you see in the editor, such as a bold paragraph, a larger title, or an image, are the exact representation of how they will actually appear: no markdown, nothing. Just the content of your page as it will be displayed.

Example of an editor built with TinyMCE
Example of an editor built with TinyMCE

Let's now see how to install and configure TinyMCE in a project using React or NextJS (Next.js for friends)! 😉

 

Prerequisites for Installation

Before starting to use TinyMCE, make sure:

  • you have a project built with React or NextJS
  • you have NodeJS and npm installed
Warning

You can also use TinyMCE with JavaScript: the process is simple, and if you need help, feel free to mention it in the comments.

 

Initializing a React or NextJS Project

If you don't have a React or NextJS project yet, here's how to create one quickly.

For a React Project

Simply initialize your project using Vite:

CONSOLE
npm create vite@latest

Select React and you're good to go. 😬

 

For a NextJS Project

If you're working with NextJS, use this command:

CONSOLE
npx create-next-app@latest

Let yourself be guided and voilà: a brand new project.

 

Installing TinyMCE

To install TinyMCE in our project, we need to use the official package @tinymce/tinymce-react.

CONSOLE
npm install @tinymce/tinymce-react

This command allows us to download TinyMCE along with all its necessary dependencies for its proper functioning.

 

Integrating TinyMCE into a Component

To use TinyMCE, the best approach is to use a dedicated component.

We will later see how to customize TinyMCE with hundreds of options: you'll be happy when you only need to apply changes to your dedicated TinyMCE component rather than to your hundreds of pages using the editor! 😉

Creating a Component Exclusively for TinyMCE

Let's create a file named TinyEditor.js:

JSX
import { Editor } from '@tinymce/tinymce-react';
import { useState } from 'react';

const TinyEditor = () => {
  const [content, setContent] = useState('');

  const handleEditorChange = (content) => {
    setContent(content);
    console.log('Edited content:', content);
  };

  return (
    <div>
      <Editor
        apiKey='your-api-key'
        initialValue="<p>Write here...</p>"
        init={{
          height: 500,
          menubar: false,
          plugins: [
            'advlist autolink lists link image charmap print preview anchor',
            'searchreplace visualblocks code fullscreen',
            'insertdatetime media table paste code help wordcount'
          ],
          toolbar:
            'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help'
        }}
        onEditorChange={handleEditorChange}
      />
      <p>Edited content: {content}</p>
    </div>
  );
};

export default TinyEditor;

To start, we import the Editor component from the TinyMCE package, which allows us to display a rich text editor.

Warning

It is mandatory to specify the apiKey property. We will generate it right after! 😉

In this example, we use the initialValue property, which allows us to set an initial value when the user first sees the text editor. This property is optional.

The init property allows us to initialize TinyMCE with the following properties:

  • height - specifies the height of the editor;
  • menubar - allows you to show or hide the menu bar (like in a real text editor);
  • plugins - this is where you add the plugins you want to use;
  • toolbar - this is where you place the plugins you've added. This allows you to organize the buttons in the way you want.

Finally, onEditorChange allows you to specify what the editor should do when a change is made. Here, we store the modified content in the state content and display its content in the console.

 

Generating an API Key to Use TinyMCE

To use TinyMCE, an API key is mandatory.

To generate it, simply create an account on TinyMCE: click this link.

Then click on "Get your API Key".

TinyMCE Dashboard
TinyMCE Dashboard

Retrieve your API key and modify your apiKey property in your TinyEditor component.

Finally, don't forget to add your domain in "Approved Domains" so that your editor can function on your site.

Adding Your Domain on TinyMCE
Adding Your Domain on TinyMCE
Warning

To ensure your editor works on your local site, also add localhost. Otherwise, TinyMCE will only load on your domain.

 

Using the Component with React

Using our TinyEditor component with React is straightforward: simply call it!

JSX
import TinyEditor from '../components/Editor';

export default function Home() {
  return (
    <div>
      <h1>My TinyMCE Editor</h1>
      <TinyEditor />
    </div>
  );
}

All that's left is to add properties that will allow you to retrieve the data from your editor.

 

The Specific Case of NextJS

With NextJS, you might encounter an error related to server-side rendering (SSR).

Indeed, TinyMCE uses many objects that are only available in the browser, like the window object.

Fortunately, there's a simple solution to disable SSR specifically for TinyMCE! 😗

To avoid the error "window is not defined", use NextJS's dynamic function to load TinyMCE only on the client side:

JSX
import dynamic from 'next/dynamic';

const TinyEditor = dynamic(() => import('../components/TinyEditor'), {
  ssr: false
});

export default function Home() {
  return (
    <div>
      <h1>My TinyMCE Editor</h1>
      <TinyEditor />
    </div>
  );
}

Our editor is now rendered exclusively on the client side, resolving the issues related to SSR.

 

Customizing TinyMCE

One of the major strengths of TinyMCE is its modularity in terms of customization. It is indeed possible to enable but also disable all the plugins you want (or almost) to meet the needs of your projects and your users.

Available Plugins with TinyMCE

TinyMCE offers numerous plugins, but not all of them are free. 😕

Fortunately, the best ones are available for free! Here's a short list of the top plugins to use in your editor:

  • autolink - to automatically create links (without using the "add link" button)
  • image - to add images
  • code - to add a code block to display a code snippet, for example
  • link - to add links
  • lists - to create lists
  • table - to add tables

The complete list of plugins available with TinyMCE is available at this link if you want to explore more possibilities.

 

Adding or Removing Plugins

Adding Plugins

To add plugins in TinyMCE, you need to specify them in the plugins property that we saw during initialization in our TinyEditor component.

Here's a small example with some of our selected plugins:

JSX
<Editor
  apiKey='your-api-key'
  init={{
    height: 500,
    plugins: 'autolink lists link image',
    toolbar: 'undo redo | bold italic | alignleft aligncenter alignright | bullist numlist outdent indent | link image',
    menubar: false
  }}
  onEditorChange={handleEditorChange}
/>

In this example:

  • autolink: automatically converts URLs into links;
  • lists: allows creating and customizing bulleted or numbered lists;
  • link: allows adding and editing links by modifying the link anchor (the link text);
  • image: allows adding images.
Good to know

Note that each added plugin provides the ability to use buttons. Some are offered by default, like undo and redo, but others come with the addition of a very specific plugin, such as:

  • lists - allows using the bullist and numlist buttons
  • link - allows using the link button
  • image - allows using the image button

Some plugins thus offer multiple buttons while others offer only one: this allows us to customize the order of the buttons in our menu.

Some buttons are available by default: this is the case with the undo and redo buttons, which allow navigating through changes made to our content.

 

Removing Plugins

If certain plugins are not necessary, simply do not add them.

For example, the same editor as our previous example but without the plugin that manages images would look like this:

JSX
<Editor
  apiKey='your-api-key'
  init={{
    height: 500,
    plugins: 'autolink lists link',
    toolbar: 'undo redo | bold italic | alignleft aligncenter alignright | bullist numlist outdent indent | link',
    menubar: false
  }}
  onEditorChange={handleEditorChange}
/>
Warning

We have removed the image plugin as well as the button associated with it (image).

 

Conclusion

TinyMCE is truly an excellent WYSIWYG editor. Very easy to integrate, easily modular to adapt it to our projects, it's no coincidence that it is today the most used editor! 😋

If you want to learn more about React or NextJS, start right now with our up-to-date React training or our NextJS training!

Category: Developers

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.

Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Read next

Understanding .env files with ReactJS

Find out how to really use the .env file with React or NextJS so you never make a mistake again.

December 9, 2024

React vs NextJS: what should you choose for your project in 2025?

Which technology should you use, React or NextJS? Discover their advantages and disadvantages to choose the one best suited to your projects.

December 9, 2024

Setting up SCSS themes and contexts with NextJs or React

You can't modify a scss variable, because scss converts its code to css, applying the variable values directly. This makes it difficult to set up a light/dark theme on your React or Next project and scss. Fortunately, there are solutions, which we'll be exploring in this article.

December 11, 2024

How to use Server Actions with NextJS

Discover why and how NextJS Server Actions improve performance on both Client Components and Server Components, and learn how to use them in your projects.

December 9, 2024

Send an email with NextJS and SendGrid for free

Have you always wanted to send emails with JavaScript? Or more specifically, how to send emails with React or NextJS? Then let's find out together how to use SendGrid! It's a quick and easy solution to set up that will help us ensure that our emails are sent and, most importantly, received.

December 9, 2024

How do I add a favicon with NextJS?

Learn how to easily add a favicon to your NextJS project with this detailed guide and also find out how to generate a favicon on demand using ImageResponse.

December 6, 2024

How to use localStorage in a NextJs or React application

The aim of this article is to teach you how to use localStorage in a Next.JS or React application. Indeed, there are a few differences with the normal use, in a vanilla application.

December 11, 2024

Why you should learn NextJS in 2025: all the benefits!

Explore why Next.js is a must-have framework for developers in 2025. Learn about its benefits, unique features and why the job market is increasingly adopting it.

December 6, 2024

Become the solopreneur you dream of being.

First project, career change, business launch: access our courses, practice on real-world cases, and move forward with clear guidance.