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
CredentialProvider
import and its usage from thesrc/libs/auth.ts
file -
remove the
src/app/api/login
folder -
update the
handleSubmit
function in thesrc/views/Login.tsx
file 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.tsx
file.
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
GoogleProvider
import and its usage from thesrc/libs/auth.ts
file. Additionally, remove the following code related to thePrismaAdapter
from 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/prisma
folder -
remove the button with the
onClick={() => signIn('google')}
prop from thesrc/views/Login.tsx
file:src/views/Login.tsx<button className='block' onClick={() => signIn('google')}>
Login with google
</button> -
remove the following envireonment variables from the
.env
file:GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET
DATABASE_URL
-
update the following in your
package.json
file:"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/client
prisma
dotenv-cli
Use the following command to remove these dependencies:
- pnpm
- yarn
- npm
pnpm remove @auth/prisma-adapter @prisma/client prisma dotenv-cli
yarn remove @auth/prisma-adapter @prisma/client prisma dotenv-cli
npm 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/auth
src/app/api/login
src/libs/auth.ts
src/contexts/nextAuthProvider.tsx
src/prisma
src/hocs/AuthGuard.tsx
src/hocs/GuestOnlyRoute.tsx
src/components/AuthRedirect.tsx
-
remove
signOut
&useSession
imports and usage from thesrc/components/layout/shared/UserDropdown.tsx
file -
remove
signIn
import and usage from thesrc/views/Login.tsx
file -
remove
NextAuthProvider
import and its usage from thesrc/components/Providers.tsx
file -
remove
src/app/[lang]/(blank-layout-pages)/(guest-only)/layout.tsx
file -
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
.env
file:NEXTAUTH_BASEPATH
NEXTAUTH_URL
NEXTAUTH_SECRET
GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET
DATABASE_URL
-
update the following in your
package.json
file:"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/client
next-auth
prisma
dotenv-cli
Use the following command to remove these dependencies:
- pnpm
- yarn
- npm
pnpm remove @auth/prisma-adapter @prisma/client next-auth prisma dotenv-cli
yarn remove @auth/prisma-adapter @prisma/client next-auth prisma dotenv-cli
npm uninstall @auth/prisma-adapter @prisma/client next-auth prisma dotenv-cli
That's it! You've successfully removed authentication completely from the full-version.