How to Add Writing Assistance to Any Javascript App | Grammarly

  • Post category:Blog

You’ve launched your app. Maybe it’s the next great blogging platform, marketplace, or social media platform. Whatever it is, your users are writing, and it’s important to you and them that they can write well. Thankfully, you’ve armed your users with a rich text editor that can do things like mark up their text, embed rich media, and tag posts with hashtags. But what about making sure that the text itself is clear, compelling, and grammatically correct? In just five minutes, you can use the Grammarly Text Editor SDK to add writing assistance to any JavaScript application.

What’s the Grammarly Text Editor SDK?

The Grammarly Text Editor SDK provides a JavaScript plugin that lets you add Grammarly’s writing assistance to any <textarea>, <input>, or contenteditable element in your application. As they type, your users will automatically get real-time writing suggestions for correctness, clarity, tone, and more, without needing to sign up for a Grammarly account. You can also customize the plugin to tailor it to your application’s UX. The core functionality is free, and you can sign up for the paid Plus plan to get advanced writing features.

Adding writing assistance to your web app

Let’s walk through integrating Grammarly with an app.

If you’d like to code along with this article, you can fork our starter templates for React, Vue, vanilla JavaScript, and HTML on You can also clone the Grammarly for Developers repository on GitHub. The starter templates are under examples and follow the naming pattern demo-[framework-name].

Create a Grammarly for Developers account

If you don’t already have one, sign up for a free Grammarly account at If you already have a Grammarly account, you can use your existing credentials to log in.

Set up your Grammarly for Developers app

Once you’ve signed in, you’ll be taken to the My Apps page, where you can create your first Grammarly for Developers app. After you’ve created your first app, you’ll automatically be taken to the App Console. There are two steps you’ll need to take in the App Console: getting your client ID and configuring your origins.

Get your client ID

Your app has a client ID that identifies your Grammarly Text Editor SDK integration. To get your client ID, navigate to the web client page located under “Clients” in the navigation menu. Then, you can grab your client ID from the quick start or find it under the Credentials header at the bottom of the page.

Configure your web app origins

Add the origin of your web app to the list of origins. You can find it in the Credentials section at the bottom of the page, just below the client ID.

Add the Grammarly Text Editor SDK dependency

Next, depending on which framework you’re using, you’ll install the appropriate npm package for the Grammarly Text Editor SDK. We have a core JavaScript library as well as framework-specific wrapper libraries for React and Vue.


If you’re using React, you can install the React wrapper library:


If you’re using Vue, you can install the Vue wrapper library:


If you’re using plain JavaScript or a framework other than React or Vue, install the core library:


If you don’t want to use a build step or are building a prototype, you can also use a content delivery network (CDN) like jsDelivr:

Add the plugin to your text editor

The last step is to add the Grammarly Text Editor Plugin to your text editor.

Using the Grammarly Text Editor component

The fastest way to add the plugin is to wrap your text editor with a Grammarly Text Editor Plugin component. In the examples below, we’re wrapping a <textarea>, but the plugin works with <input>, or contenteditable elements as well.


In React and Vue, you’ll import the <GrammarlyEditorPlugin> component and use it to wrap your text editor. Make sure to pass in your client ID.



In plain JS and HTML, you’ll wrap your text editor with a <grammarly-editor-plugin> component and pass your client ID when initializing the SDK. If you’re using the core JavaScript library, you’ll do this by calling Grammarly.init() and passing in your client ID.


In HTML, you can initialize the SDK by passing your client ID to the script tag as a parameter. Loading the SDK through a CDN is a good approach for development but isn’t meant for production.

Now your writing assistance integration is complete! 🎉

An example text editor, containing underlines and a Grammarly suggestion card to show that the Grammarly Text Editor Plugin is currently running in the editor. The Grammarly button appears in the bottom right corner. The Grammarly Text Editor Plugin running in a text editor. The Grammarly button appears in the bottom right corner.

Try writing some text in your text editor. The Grammarly button should appear in the bottom right corner of your web page. If it isn’t showing, check out our article on diagnosing issues.

Wrapping up

You’ve learned how to add writing assistance to any JavaScript application using the Grammarly Text Editor SDK, but this is just the beginning. You can explore our docs to learn how to configure the behavior of the plugin, set the default English dialect, and use CSS to customize the plugin’s theme. You can also demo configuration options in real time without writing a line of code using the Configurator.

If you have questions about the Grammarly Text Editor SDK or want to make a feature request, join us on the Grammarly for Developers discussion board on GitHub. To stay up to date on the SDK’s development as we add new features, follow @GrammarlyDevs on Twitter. We’d love to hear about what you’re building.

Source link