You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make next-auth framework agnostic (Vite, Vue, Express...) #2294
v4 has been marked as stable, and the source code has been refactored to be Next.js API routes agnostic. It is still undocumented, but we are ready to discuss how to integrate with other frameworks in the open. If you are developing in one of those communities (Vue, Svelte etc.), feel free to reach out!
Reacted by Sai Krishna, Balázs Orbán, Alex, Alexander Rozhkov, Huy Giang, Mart Sõmermaa, Benjamin Kniffler, Sylvain Duchesne, Leonid Meleshin, siegerts and 8 more
Reacted by Iain Collins, Mart Sõmermaa, Graham Tremper, Maxime and Didi Keke
I'm very hopeful about this. We might have to do small adjustments, but I think in most cases, a tiny wrapper on top of NextAuth would be enough. The ground work could be done as early as in v4 (aiming for a release this summer).
I already started to decouple/better namespace our client code, in v4 it will be under next-auth/react
The ground work could be done as early as in v4 (aiming for a release this summer)
Exciting 😍.
Will I then be able to use NextAuth.js in a let's say Vite + Vue app?
I'm developing a framework ("Vike") on top of Vite + vite-plugin-ssr + RPC and I'd love to offer authentication to both my React and Vue users with NextAuth.js.
Thanks for your wonderful work, it's lovely to see the JS ecosystem maturing.
If we rewrite the backend a bit, as long as your framework can set cookies and do redirects and handle basic POST/GET requests, it should be good. We would need to separate the server/index.js file in a way that it is only a tiny wrapper for Next.js and the core stuff could be framework agnostic.
Had a quick look over the source and yea should be fairly easy to port it to Vue's composition API; there aren't that many React specific things going on. AFACIT a common module that factors out the React/view-framework agnostic code should make porting quite easy.
Can't wait to see NextAuth.js to become the de facto standard — Vite & Vue users will love it :-).
Reacted by Balázs Orbán, Mart Sõmermaa and siegerts
It's quite amazing that you don't even need to install react to use it with Nuxt. Here's a repo on how someone could use next-auth with nuxt! https://nuxt-next-auth.vercel.app/
@wobsoriano Wow neat... would you be up to develop some Vue composition functions? Basically like next-auth/react but for Vue. I'd happily assist/review.
That's awesome @wobsoriano! Looking forward to set some time aside for this enhancement, so we can start the expansion! I will probably need some help for the Vue client.
<template><div><divv-for="provider in Object.values(providers)" :key="provider.id"><button@click="signIn(provider.id)">Sign in with {{ provider.name }}</button></div></div></template><script>import{defineComponent}from'@nuxtjs/composition-api';import{getProviders,signIn}from'~/modules/next-auth/client';exportdefaultdefineComponent({middleware: 'guest',setup(){return{
signIn
}},asyncasyncData(){constproviders=awaitgetProviders()return{
providers
}}})</script>
and adding configs directly to nuxt.config.js
importProvidersfrom'next-auth/providers';exportdefault{// other nuxt confignextAuth: {providers: [Providers.GitHub({clientId: process.env.GITHUB_CLIENT_ID,clientSecret: process.env.GITHUB_CLIENT_SECRET}),],}}
@wobsoriano Neat neat 👌. What was your reason to use Nuxt's composition API instead of Vue's one? What do you think of factoring out the common code between next-auth/client and your version? That way anyone can use NextAuth.js with anything e.g. with Vue's composition API
@wobsoriano Neat neat 👌. What was your reason to use Nuxt's composition API instead of Vue's one? What do you think of factoring out the common code between next-auth/client and your version? That way anyone can use NextAuth.js with anything e.g. with Vue's composition API
Actually published a simple Nuxt module for this that later we can add to next-auth/client since Nuxt 2.0 supports Vue 2 only
Nice 👍. Ideally nuxt-next-auth would be only a thin wrapper around a next-auth view-framework agnostic library. Right now there is a lot of duplicated code between next-auth/client and nuxt-next-auth right?
Nice 👍. Ideally nuxt-next-auth would be only a thin wrapper around a next-auth view-framework agnostic library. Right now there is a lot of duplicated code between next-auth/client and nuxt-next-auth right?
That is really cool! 👏 I wonder if there is anything I should do/expose for this to be a viable base to build on top of. I would like to get the PR reviewed so we can get closer to a v4 stable release.
It looks like you already have a working Nuxt & SvelteKit POC, which is awesome 😅
Svelte and Vue clients could follow. In short, a client in next-auth is a list of methods that communicate with the backend REST API. The most important functionality is
a session cache that can re-fetch the session in intervals to avoid stale data
synced session state between tabs
signIn method to start the sign-in process directly to a provider, or redirect to the sign-in page
That is really cool! 👏 I wonder if there is anything I should do/expose for this to be a viable start to work on top of. I would like to get the PR reviewed so we can get closer to a v4 stable release.
It looks like you already have a working Nuxt & SvelteKit POC, which is awesome 😅
I think these functions can be used by Vue/Svelte (except useSession)
And probably SessionProvider neither. I think we should create standalone clients anyway, in case something changes in Svelte or Vue in the future. I might also want to refactor the React client without worrying about crashing anything in other libraries.
And probably SessionProvider neither. I think we should create standalone clients anyway, in case something changes in Svelte or Vue in the future. I might also want to refactor the React client without worrying about crashing anything in other libraries.
Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep it open. (Read more at #912) Thanks!
It is. I'm taking a small break from the project (low maintenance is still provided) for the holidays, and to be able to better focus on my new job. Will come back the next year.
Small update here, we are in the works to convert this repo to a monorepo that will contain all the projects like adapters, docs, and examples, with the core itself. this will open up for creating new packages for different frameworks. Once we are satisfied with the monorepo setup (#3650) we can get around this issue much more easily!
Reacted by Jack Kennedy, Caspar Wamik and Jonas Strassel
Activity
balazsorban44 commentedon Jul 1, 2021
I'm very hopeful about this. We might have to do small adjustments, but I think in most cases, a tiny wrapper on top of
NextAuthwould be enough. The ground work could be done as early as in v4 (aiming for a release this summer).I already started to decouple/better namespace our client code, in v4 it will be under
next-auth/reactSee #1473
brillout commentedon Jul 29, 2021
Exciting 😍.
Will I then be able to use NextAuth.js in a let's say Vite + Vue app?
I'm developing a framework ("Vike") on top of Vite + vite-plugin-ssr + RPC and I'd love to offer authentication to both my React and Vue users with NextAuth.js.
Thanks for your wonderful work, it's lovely to see the JS ecosystem maturing.
balazsorban44 commentedon Jul 29, 2021
If we rewrite the backend a bit, as long as your framework can set cookies and do redirects and handle basic POST/GET requests, it should be good. We would need to separate the
server/index.jsfile in a way that it is only a tiny wrapper for Next.js and the core stuff could be framework agnostic.I liked the Sveltekit endpoint approach:
https://kit.svelte.dev/docs#routing-endpoints
brillout commentedon Jul 29, 2021
Neat & yes, the backend integration should work then.
How about Vue?
You mentioned:
Will we be able to have a
next-auth/vue? I can see myself (and potentially other Vue users) to contribute.balazsorban44 commentedon Jul 29, 2021
Yes, that would be easy I think.
Here is the source code for the react specific frontend:
https://github.com/nextauthjs/next-auth/blob/next/src/client/react.js
We still have to work out some small things like tab syncing and invalidation of the session, but other than that it should not be hard, hopefully.
brillout commentedon Jul 29, 2021
👌.
Had a quick look over the source and yea should be fairly easy to port it to Vue's composition API; there aren't that many React specific things going on. AFACIT a common module that factors out the React/view-framework agnostic code should make porting quite easy.
Can't wait to see NextAuth.js to become the de facto standard — Vite & Vue users will love it :-).
wobsoriano commentedon Jul 30, 2021
It's quite amazing that you don't even need to install
reactto use it withNuxt. Here's a repo on how someone could usenext-authwithnuxt! https://nuxt-next-auth.vercel.app/https://github.com/wobsoriano/nuxt-next-auth
brillout commentedon Jul 30, 2021
@wobsoriano Wow neat... would you be up to develop some Vue composition functions? Basically like
next-auth/reactbut for Vue. I'd happily assist/review.balazsorban44 commentedon Jul 30, 2021
That's awesome @wobsoriano! Looking forward to set some time aside for this enhancement, so we can start the expansion! I will probably need some help for the Vue client.
wobsoriano commentedon Jul 31, 2021
Copied contents of
next-auth/clientand updated some lines to make it work with Vue's Composition API https://github.com/wobsoriano/nuxt-next-auth/blob/master/modules/next-auth/client.jsMost if it are working now -
useSession,getSession,signIn,signOut,getCsrfToken,getProviders.and adding configs directly to
nuxt.config.jsbrillout commentedon Aug 2, 2021
@wobsoriano Neat neat 👌. What was your reason to use Nuxt's composition API instead of Vue's one? What do you think of factoring out the common code between
next-auth/clientand your version? That way anyone can use NextAuth.js with anything e.g. with Vue's composition APIwobsoriano commentedon Aug 3, 2021
Actually published a simple Nuxt module for this that later we can add to next-auth/client since Nuxt 2.0 supports Vue 2 only
https://github.com/wobsoriano/nuxt-next-auth
brillout commentedon Aug 3, 2021
Nice 👍. Ideally
nuxt-next-authwould be only a thin wrapper around anext-authview-framework agnostic library. Right now there is a lot of duplicated code betweennext-auth/clientandnuxt-next-authright?wobsoriano commentedon Aug 3, 2021
Yeah, the whole client.js file is copied
42 remaining items
balazsorban44 commentedon Oct 13, 2021
That is really cool! 👏 I wonder if there is anything I should do/expose for this to be a viable base to build on top of. I would like to get the PR reviewed so we can get closer to a v4 stable release.
It looks like you already have a working Nuxt & SvelteKit POC, which is awesome 😅
Svelte and Vue clients could follow. In short, a client in
next-authis a list of methods that communicate with the backend REST API. The most important functionality issignInmethod to start the sign-in process directly to a provider, or redirect to the sign-in pagesignOutempties the cacheDocs here:
wobsoriano commentedon Oct 13, 2021
I think these functions can be used by Vue/Svelte (except useSession)
balazsorban44 commentedon Oct 13, 2021
And probably
SessionProviderneither. I think we should create standalone clients anyway, in case something changes in Svelte or Vue in the future. I might also want to refactor the React client without worrying about crashing anything in other libraries.Do you want me to do anything more on the PR?
wobsoriano commentedon Oct 13, 2021
all good for now :D
brillout commentedon Dec 13, 2021
I think it's still relevant :-)
balazsorban44 commentedon Dec 13, 2021
It is. I'm taking a small break from the project (low maintenance is still provided) for the holidays, and to be able to better focus on my new job. Will come back the next year.
Cheers 🍻
brillout commentedon Dec 13, 2021
That's actually good timing as we'll be able to show you the Vike + NextAuth integration next year :-).
Happy holidays 🎄.
dohomi commentedon Jan 18, 2022
I am using NextJS for the production app and Storybook for the UI testing solution and UI regression testing.
Is it possible to use NextAuth currently already with v4 and Storybook? I couldn't find any pointers so far.
balazsorban44 commentedon Feb 5, 2022
Small update here, we are in the works to convert this repo to a monorepo that will contain all the projects like adapters, docs, and examples, with the core itself. this will open up for creating new packages for different frameworks. Once we are satisfied with the monorepo setup (#3650) we can get around this issue much more easily!