Jump to content
Search Community

GSAP not works with NextJS properly

Aditya Sutar test
Moderator Tag

Recommended Posts

Hi @Aditya Sutar and welcome to the GreenSock forums!

 

Unfortunately the URL of the image you posted seems broken so I'm unable to see the error you're reporting.

 

Also gsap is the core of the engine not a plugin, so there is no need to register it and you are not importing ScrollTrigger so that could be a source for an error as well.

 

Please give this a try:

import gsap from "gsap-trial/dist/gsap";
import { ScrollTrigger } from "gsap-trial/dist/ScrollTrigger";
import { ScrollSmoother } from "gsap-trial/dist/ScrollSmoother";

gsap.registerPlugin(ScrollTrigger, ScrollSmoother);

Finally here are some simple starters for using GSAP in a NextJS App:

 

ScrollTrigger Starter:

https://stackblitz.com/edit/nextjs-5cm4qn?file=pages%2F_app.js,pages%2Findex.js

 

ScrollSmoother Starter:

https://stackblitz.com/edit/nextjs-efumgr?file=pages%2F_app.js,pages%2Findex.js

 

If you keep having issues, please fork one of the examples and use your code in order to create a minimal demo (please try to keep the demos as small as possible).

 

Happy Tweening!

Link to comment
Share on other sites

It's totally fine to use gsap-trial on your local machine or on CodePen/CodeSandbox/Stackblitz, but it will NOT work if you deploy it anywhere else. ScrollSmoother is a members-only benefit of Club GreenSock and it looks like you haven't joined yet. https://greensock.com/club

 

As for the other error, it's very difficult to diagnose by just glancing at that screenshot. It sounds like maybe you didn't register ScrollTrigger as a plugin (ScrollSmoother is built on top of ScrollTrigger). 

 

If you need more help, please make sure you provide a minimal demo, like a CodeSandbox, CodePen, or Stackblitz so we can see the issue in context. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...