Jump to content
Search Community

Good way to register GSAP Plugins in Next.JS App router, and how many many times we can do it?

devanshdsoni

Go to solution Solved by Rodrigo,

Recommended Posts

devanshdsoni
Posted

I am using Next JS App router, and I am confused while registering the plugin. 
Is there any way where I can register all plugins at once? 
or any other way for this?

  • Like 1
  • Solution
Posted

Hi,

 

The ideal way would be to register the plugins is to do it in the outmost layout file, as shown in this demo:

https://stackblitz.com/edit/stackblitz-starters-cxedmc?file=app%2Flayout.tsx

 

Is worth mentioning though that there is absolutely no issue if a plugin is registered more than once, so you won't run into any issues if you do that.

 

Hopefully this helps.

Happy Tweening!

  • Like 1
  • Thanks 1
  • 3 months later...
Posted

@joyboy Yep nothing wrong with that approach, although is worth noticing that client components are still rendered on the server and hydrated on the client as they are in the pages router (the way Next always worked before).

 

Are you noticing a performance issue or some problem by setting a main layout file as a use client file?

 

Happy Tweening!

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...