Logo

dev-resources.site

for different kinds of informations.

An Alternative To Editor.js: BlockNote For React

Published at
9/16/2024
Categories
nextjs
typescript
approuter
react
Author
nifty-little-me
Categories
4 categories in total
nextjs
open
typescript
open
approuter
open
react
open
Author
15 person written this
nifty-little-me
open
An Alternative To Editor.js: BlockNote For React

So, previously I was searching for a great WYSIWYG text editor I can add to a few projects of mine. And some time ago, I discovered BlockNote, and instantly I fell in love.

But what is BlockNote and how does it compare to other options like Editor.js or even Quill? In this article, we will talk all about it. So, have a seat and read this article that can potentially answer your questions and/or introduce you to something that will change your project for the better. Letโ€™s dive in!

Screenshot

What The Heck Is BlockNote???

BlockNote is an open-source block-based rich text editor built on top of ProseMirror and TipTap. Like Editor.js, BlockNote separates elements into blocks (headers, paragraphs, images, etcโ€ฆ).

BlockNote was made for React, which is convenient for me, given the fact that I am currently working with the Next.js framework. People who work with Notion will recognize the style.

How Do I Add BlockNote To My Code?

This article would be a throwaway if I did not go over how to actually add BlockNote to your project. So, to make this article actually useful, letโ€™s go over how you start using BlockNote in your next.js project even though the documentation is super clear.

Create a next.js project if you havenโ€™t done so already by running this command in your terminal:

npx create-next-app@latest
Enter fullscreen mode Exit fullscreen mode

Run the command npm install @blocknote/core @blocknote/react @blocknote/mantine to install the necessities for BlockNote.

Now we need to create a components folder inside our projects, but keep it outside the app folder. Inside the folder, create a file called Editor.tsx. Copy and paste this code:

"use client";
import "@blocknote/core/fonts/inter.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";

export default function Editor() {
  const editor = useCreateBlockNote();

  return <BlockNoteView editor={editor} />;
}
Enter fullscreen mode Exit fullscreen mode

Now, inside your page.tsx file, copy and paste this code:

import dynamic from "next/dynamic";

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

function App() {
  return (
    <div>
      <Editor />
    </div>
  );
}
Enter fullscreen mode Exit fullscreen mode

Well, this was a short article; however, thereโ€™s plenty more to cover when it comes to BlockNote and this was just an introduction. If you liked this article, subscribe to my newsletter. Also, follow me on Medium.

Happy Coding!

approuter Article's
23 articles in total
Favicon
Show a loading screen when changing pages in Next.js App router
Favicon
Learning Next.js 13 App Router: A Comprehensive Guide ๐Ÿš€
Favicon
Guide to build a modern Web App using Next.js 14 (App Router), Fully authentication (NextAuth), Theming and i18n
Favicon
A practical Guide - Migrating to Next.js App Router
Favicon
Adding Chat Functionality To Your Next.Js Project With Firebase
Favicon
Spicing Up Your Next.Js Projects With 3D: What Are Your Options?
Favicon
No More Pages
Favicon
How To Create A Basic Infinity Canvas For Your Next.Js Project
Favicon
How To Implement Text-To-Speech Functionality For BlockNote In Next.Js
Favicon
How To Add Drag-And-Drop Functionality With Editable Draggable Items In Next.js
Favicon
Adding Drag And Drop Functionality In Your Next.Js Project Without A Library
Favicon
Creating NPM Packages in Next.Js for Next.Js
Favicon
Using Firebase To Store Folders and BlockNote Documents In Next.Js
Favicon
An Alternative To Editor.js: BlockNote For React
Favicon
How To Add Editor.Js To Your Next.Js Code
Favicon
How To Use The Quill Rich Text Editor in Your Next.Js App Router Project
Favicon
Simple NextJS GraphQL client
Favicon
Implementing Internationalization (i18n) in Next.js 14 using App Router
Favicon
Web Streams API in Action: Delivering 6000+ Log Lines Concurrently Across 20 Tabs
Favicon
How to use React-Toastify with Next.js App router
Favicon
NextAuth - Implementando "Custom Login Pages" com "Credentials Sign in" utilizando App Router
Favicon
The origin of App Router - A Next.Js Rewind
Favicon
How to add multiple routers in a node application without using app.use() for each router ?

Featured ones: