-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: @toss/use-funnel Idea Proposal for supporting App DIrectory(Nextjs13) #322
Comments
I think it would be better to utilize NextJS's router object like we already do. Creating a custom router is beyond the scope of maintenance for the slash library project. |
Yes, that's correct. There might be challenges similar to the ones you mentioned in creating the custom So, what would be a recommended approach to support NextJS's app router? Would it be necessary to develop an implementation specifically tailored for app routers? |
I think the slash library should provide an implementation for AppRouter (e.g. @toss/use-funnel/appdirectory), or people who like the behavior of this useFunnel custom hook should create their own next-use-funnel library. I think it would be nice to create the next-use-funnel library first, and then provide a later implementation in the slash library. |
I agree as well. |
I looked at the entire code and realized that the dependency on
In conclusion, rewriting toss code for Next.js 13 App Directory compatibility shouldn't be too difficult.. I've already started working on that for use by my team. |
Well, it seems I was wrong, the easiest way to implement the existing behavior of useFunnel in App Directory was to create a custom client hook that detects the popstate behavior of the window and returns the current searchParams. This was no more productive than creating @toss/router, or contributing code to support the shallow behavior of next/navigation. |
Update: By giving up some behavior, an implementation via the next/navigation router is possible without complicated access to browser history. I'll share a build of the library later. |
@CodePsy-2001 wow! I feel exciting your works! I hope see your works ASAP!! |
Hello! Sorry for the late update. Please refer to this source code. npm i next-use-funnel
# or
yarn add next-use-funnel https://github.com/CodePsy-2001/next-use-funnel My library has 100% test coverage and all interfaces are compatible with
|
Package Scope
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 theNext.js
's App directory.Currently,
@toss/use-funnel
does not provide full support forNext.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 bynext/navigation
, while the Pages directory usesnext/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 theuseRouter
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 throughnext/navigation
returns anAppRouterInstance
that doesn't align adequately with the existingNextRouter
object fromnext/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 theuseRouter
called withinwithState
.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.Additional context
#228
next-router-not-mouted in
App Dir
The text was updated successfully, but these errors were encountered: