Remove Authentication from full-version
Only for those who are using the full-version.
Overview
In this guide, we'll walk you through the process of removing authentication partly or completely from the full-version.
Remove Credentials Provider from the full-version
To remove the Credentials Provider from the full-version, you'll need to follow the steps below:
-
remove
CredentialProviderimport and its usage from thesrc/libs/auth.tsfile -
remove the
src/app/api/loginfolder -
update the
handleSubmitfunction in thesrc/views/Login.tsxfile to the following:- TS
- JS
src/views/Login.tsxconst handleSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault()
}src/views/Login.jsconst handleSubmit = (event) => {
event.preventDefault()
}Also, remove the unused hooks and imports from the
src/views/Login.tsxfile.
That's it! You've successfully removed the CredentialsProvider from the full-version.
Remove Google Provider from the full-version
To remove the Google Provider from the full-version, you'll need to follow the steps below:
-
remove
GoogleProviderimport and its usage from thesrc/libs/auth.tsfile. Additionally, remove the following code related to thePrismaAdapterfrom this file:- TS
- JS
src/libs/auth.ts- import { PrismaAdapter } from '@auth/prisma-adapter'
- import { PrismaClient } from '@prisma/client'
- import type { Adapter } from 'next-auth/adapters'
- const prisma = new PrismaClient()
- adapter: PrismaAdapter(prisma) as Adapter,src/libs/auth.js- import { PrismaAdapter } from '@auth/prisma-adapter'
- import { PrismaClient } from '@prisma/client'
- const prisma = new PrismaClient()
- adapter: PrismaAdapter(prisma), -
remove the
src/prismafolder -
remove the button with the
onClick={() => signIn('google')}prop from thesrc/views/Login.tsxfile:src/views/Login.tsx<button className='block' onClick={() => signIn('google')}>
Login with google
</button> -
remove the following envireonment variables from the
.envfile:GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETDATABASE_URL
-
update the following in your
package.jsonfile:"scripts": {
- "migrate": "dotenv -e .env -- npx prisma migrate dev",
- "postinstall": "prisma generate && npm run build:icons"
+ "postinstall": "npm run build:icons"
},
- "prisma": {
- "schema": "./src/prisma/schema.prisma"
- } -
remove the following dependencies from your project:
@auth/prisma-adapter@prisma/clientprismadotenv-cli
Use the following command to remove these dependencies:
- pnpm
- yarn
- npm
pnpm remove @auth/prisma-adapter @prisma/client prisma dotenv-cliyarn remove @auth/prisma-adapter @prisma/client prisma dotenv-clinpm uninstall @auth/prisma-adapter @prisma/client prisma dotenv-cli
That's it! You've successfully removed the GoogleProvider and PrismaAdapter from the full-version.
Remove Authentication completely from the full-version
In this section, we'll walk you through the process of removing authentication completely from the full-version.
To remove authentication completely from the full-version, you'll need to follow the steps below:
-
remove the following files & folders and their imports from the project:
src/app/api/authsrc/app/api/loginsrc/libs/auth.tssrc/contexts/nextAuthProvider.tsxsrc/prismasrc/hocs/AuthGuard.tsxsrc/hocs/GuestOnlyRoute.tsxsrc/components/AuthRedirect.tsx
-
remove
signOut&useSessionimports and usage from thesrc/components/layout/shared/UserDropdown.tsxfile -
remove
signInimport and usage from thesrc/views/Login.tsxfile -
remove
NextAuthProviderimport and its usage from thesrc/components/Providers.tsxfile -
remove
src/app/[lang]/(blank-layout-pages)/(guest-only)/layout.tsxfile -
move all the files or folders from the
src/app/[lang]/(blank-layout-pages)/(guest-only)directory to thesrc/app/[lang]/(blank-layout-pages)directory and remove the empty(guest-only)directory -
move all the files or folders from the
src/app/[lang]/(dashboard)/(private)directory to thesrc/app/[lang]/(dashboard)directory and remove the empty(private)directory -
remove the following envireonment variables from the
.envfile:NEXTAUTH_BASEPATHNEXTAUTH_URLNEXTAUTH_SECRETGOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETDATABASE_URL
-
update the following in your
package.jsonfile:"scripts": {
- "migrate": "dotenv -e .env -- npx prisma migrate dev",
- "postinstall": "prisma generate && npm run build:icons"
+ "postinstall": "npm run build:icons"
},
- "prisma": {
- "schema": "./src/prisma/schema.prisma"
- } -
remove the following dependencies from your project:
@auth/prisma-adapter@prisma/clientnext-authprismadotenv-cli
Use the following command to remove these dependencies:
- pnpm
- yarn
- npm
pnpm remove @auth/prisma-adapter @prisma/client next-auth prisma dotenv-cliyarn remove @auth/prisma-adapter @prisma/client next-auth prisma dotenv-clinpm uninstall @auth/prisma-adapter @prisma/client next-auth prisma dotenv-cli
That's it! You've successfully removed authentication completely from the full-version.