-
Notifications
You must be signed in to change notification settings - Fork 330
Description
Package Scope
- Add to an existing package
- New package
Package name:@toss/use-funnel
Overview
Idea Proposal for Supporting the 'App' Directory in Next.js 13(It is Linked issue #228)
Describe the solution you'd like
I have attempted to make @toss/use-funnel support the Next.js's App directory.
Currently, @toss/use-funnel does not provide full support for Next.js@^13. The reason is that it does not support the App directory.
This is seem to Next.js's App directory supports routing using the AppRouter provided by next/navigation, while the Pages directory uses next/router for routing.
Initially, I thought that to enable support for the App directory of Next.js 13 in @toss/use-funnel, it might be possible to receive the useRouter hook from an external source and return the Router object. Although there were slight differences in the signatures of the push and replace methods between the two Router objects, the existence of these methods seemed to make this approach possible.
During the process of testing this approach, I discovered that the useRouter provided through next/navigation returns an AppRouterInstance that doesn't align adequately with the existing NextRouter object from next/router (notably lacking the query attribute). Furthermore, implementing this approach could lead to significant API changes and potentially impact @toss/use-query-param, which is used by @toss/use-funnel. Additionally, I couldn't find a way to inject a router object into the useRouter called within withState.
As an alternative, I propose creating a custom router package named @toss/useRouter. This approach could potentially allow both @toss/use-query-param and @toss/use-funnel to leverage a custom router, addressing these issues.
Another possible solution is temporarily segregating the implementation of useFunnel to specifically support the App directory.