To configure Quill Editor in a Next.js application, follow these steps:
Install Quill: First, install the react-quill package using npm:
npm install react-quill
Import Quill CSS: In your _app.js file, import the Quill CSS to style the editor:
import 'react-quill/dist/quill.snow.css';
Dynamically Import Quill: To avoid including Quill on the server-side, dynamically import it using next/dynamic. While it’s loading, display a loading state:
import dynamic from 'next/dynamic';
const QuillNoSSRWrapper = dynamic(import('react-quill'), {
ssr: false,
loading: () => <p>Loading...</p>,
});
Configure Quill Features: Customize Quill by configuring its toolbar and formats. Here’s an example:
const modules = {
toolbar: [
[{ header: '1' }, { header: '2' }, { font: [] }],
[{ size: [] }],
['bold', 'italic', 'underline', 'strike', 'blockquote'],
[{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }],
['link', 'image', 'video'],
['clean'],
],
clipboard: {
matchVisual: false, // Toggle to add extra line breaks when pasting HTML
},
};
const formats = [
'header', 'font', 'size', 'bold', 'italic', 'underline', 'strike',
'blockquote', 'list', 'bullet', 'indent', 'link', 'image', 'video',
];
export default function Home() {
return (
<QuillNoSSRWrapper
modules={modules}
formats={formats}
theme="snow"
/>
);
}