NextJS Installation
Integrating the widget into a NextJS app
This guide will help you integrate the Squid Widget into your NextJS application. For a complete working example, check out our full NextJS example.
We have also built a NextJS 14 example.
Prerequisites
Ensure you have completed the steps in the Installing the Widget guide before proceeding.
Installation Steps
Step 1: Install Dependencies
Install the Squid Widget and necessary dependencies:
yarn add @0xsquid/widget@^3.0.10Step 2: Configure NextJS
The configuration differs based on your NextJS version:
For NextJS 13.1 and newer
Add the following to your next.config.js:
const nextConfig = {
transpilePackages: ["@0xsquid/widget", "@0xsquid/react-hooks"]
}
module.exports = nextConfigFor NextJS versions older than 13.1
Install the
next-transpile-modulespackage:
Update your
next.config.js:
Step 3: Integrate the Widget
Add the Squid Widget to your desired page. For example, in src/pages/index.tsx:
Replace <your-integrator-id> with the Integrator ID you received from Squid.
Customization
To customize the widget's appearance and behavior:
Use the Squid Widget Studio to generate a custom configuration.
Copy the generated config and paste it into your
configprop.
Running Your NextJS App
After setting up the widget, you can start your NextJS development server:
Troubleshooting
If you encounter any issues:
Ensure you're using the latest version of the widget (^3.0.10).
Check that you've correctly configured the
next.config.jsfile.Verify that you've added the correct
integratorIdandapiUrlin the widget config.Review the Migration Guide if you're upgrading from an earlier version.
Last updated