Jump to content
Search Community

How to use gsap in Next js 13 / app directory?

Romanus test
Moderator Tag

Recommended Posts

Hello! Recently Next js has been updated to version 13. Added app directory.
I have a server component, the text in which is loaded from the database. I would like to animate this text using gsap.
I can't figure out how to do it right. Animations can only be added in client components, and loaded from the database only in server components.
I would be very grateful for an example with good practice Next 13 and gsap

  • Like 1
Link to comment
Share on other sites

Hi,

 

This is a working example for using ScrollSmoother in a NextJS app using the app folder. Basically the approach is to create the ScrollSmoother instance in the main layout component and check the pathname of Next's router to revert and create the ScrollSmoother instance via GSAP Context.

 

https://stackblitz.com/edit/stackblitz-starters-lq58ww

 

If someone gets or finds a better way to approach this, we're all ears. In no way we want to impose a way of doing things but to create a healthy and constructive debate so we all can find the best approach to these issues and features.

 

Happy Tweening!

  • Thanks 1
Link to comment
Share on other sites

  • 11 months later...

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