MDB React & Next.js integration
How to use React with Next.js - free starter
MDB React integration with Next.js. Installation, various examples of implementation and much more.
Lets see how to integrate Next.js with MDB 5 across our layout, components, and utilities.
Creating Next.js app
Prerequisites
Before starting the project make sure to install Node LTS (14.6.x or higher).
Create a new Next.js app and navigate to its directory
MDB installation
Step 1
Install MDB and Font Awesome
Step 2
CSS import
Add these lines in app/layout.tsx file.
Roboto font (optional)
Copy the code from this snippet to change font:
Step 3
Launch your app.
Prerequisites
Before starting the project make sure to install Node LTS (14.6.x or higher).
Create a new Next.js app and navigate to its directory
MDB installation
Step 1
Install MDB and Font Awesome
CSS import
Add these lines in pages/_app.js file.
Roboto font (optional)
Create a custom pages/_document.js and import Roboto font in the head
section.
You can read more about Document in the official Next.js documentation.
Set font family globally in styles/globals.css as in the example:
Step 2
Launch your app.
Usage
To use MDB React inside your Next.js app simply navigate to app/page.tsx or pages/index.js and try the following example.
Troubleshooting
When using a component which refers to window
, document
or any object
undefined on the server side, this error may show up:
The solution is to use our MDBClientOnly
component, or a dynamic import with SSR disabled for problematic components.