-
Notifications
You must be signed in to change notification settings - Fork 162
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
Accessing composables in the DevTools #216
Comments
You want to access client state from a composable to your own DevTools view, did I understand correctly? Composables are compile time so at runtime we can't import them dynamically ( The solution I can think about, is that maybe you could register a dev-time-only plugin to expose the state to somewhere like the nuxt/app instance, and access the instance using |
Thanks for your quick answer! Ill have a shot at this and let you know how it goes! |
@antfu Do you think it's a good idea to provide example const auth = useAuth()
return {
provide: {
auth
}
} so it can be accessible like: |
Hi @arashsheyda and @antfu Thanks again for both of your help! I used a similar approach as you outlines @arashsheyda and it works now! What is the future plan for composable inside the DevTools? I generally prefer the Syntax of composables over that of plugins, which is why we went with that route initially. Will there be any downsides to providing a composable + plugin now (as we are only adding this for DevTools support). |
As I mentioned, auto-imported composables are compiling time, while DevTools is runtime + server config. So for devtools, your composable might not even be shipped to composable. We might be able to do a proxy plugin like you did to forward them, but that might be inefficient and might not be commonly used. I think your custom plugin approach works perfectly. |
Sounds good! Thanks for all your help ❤️ |
Hello! Thank you for all the time and hard work you have put into this project! It really sets Nuxt apart from Next and other frameworks! 🥳
We at the sidebase team are now slowly looking to add a Nuxt DevTools integration for our authentication package. I have been browsing the docs and source code for a while now and have also looked at how other modules handled creating their pages, however I have sadly not been able to find a solution.
We are using one main composable for authentication in
@sidebase/nuxt-auth
nameduseAuth()
, which returns information about the current session, available providers and much more. This data is super helpful for debugging issues with our authentication and we would love to add a browser for this data inside the DevTools. How can I access the composable with the correct information inside the DevTools? Whenever I try to use it (without importing or importing it from#imports
) it says it does not exist. When I try importing it from the source or dist folder it also does not work. Can you give me any pointers?Thanks a lot in advance!
For reference here is the PR I am working in, along with the replication of our setup: sidebase/nuxt-auth#364
The text was updated successfully, but these errors were encountered: