Authentication
How to implement authentication in your Next.js project.
In this section we will explain to setup authentication in your project.
Create a Restricted Page
To create a Restricted page (logged in user can access) wrap your page component by SecurePage component. like below example.
Redirect User after login
We have implemented functionality to redirect user after login successfully in AuthPage component.
To change redirection path after user login go to authentication / auth-page-wrappers / AuthPage
and update the following code.
Authentication Methods
We are proving two authentication method and base structure of auth methed (Basic Auth) in this template.
Firebase
JWT Auth
Firebase
Firebase is one of authentication method which is implemented in this template.To enable this method for your project follow steps given below.
Configuring the App at Firebase official website In order to use Firebase authentication service, firstly you need to configure your app at the Firebase official website. By configuring, you will get some credentials, you need to add that credentials in the application.
Update Credentials To updated Firebase credentials, open config.js file placed at:
authentication / auth-methods / firebase-auth / config.js
In this file, you will find a constant object config which contains the credential properties, you need to add your credentials to those properties.Activate Firebase To activate Firebase open
authentication / index.js
file and update value like below example.
JWT Auth
JWT auth is another auth method implemented in this template. To enable this method follow steps given below:
Setup Auth Server Very first step to enable JWT auth is setup your JWT auth server if not setup. We are providing laravel with JWT auth impletement in servers.zip file with this template when you buy Jumbo. You can use that laravel setup server if you not have JWT auth server.
Update Credentials To updated JWT Auth credentials, open config.js file placed at:
authentication / auth-methods / jwt-auth / config.js
In this file,update server user where your auth server is installed. see example:
Activate JWT Auth To activate JWT Auth open
authentication / index.js
file and update value like below example.
Basic Auth
Basic auth us a base structure for auth method. You can use it for your custom Auth method.
You can find Basic Auth at here authentication / auth-methods / basic-auth
Last updated