Package Exports
- @lineuxyz/next-auth-server-side
- @lineuxyz/next-auth-server-side/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lineuxyz/next-auth-server-side) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
next-auth-server-side: SSR Authentication Helper
Next auth server side is a library designed to facilitate server-side rendered authentication with Next.js. It helps developers handle authentication tokens, catch request errors, and manage redirections seamlessly.
Installation
To install the library:
NPM
npm install @lineuxyz/next-auth-server-side --saveYarn
yarn add @lineuxyz/next-auth-server-side --saveUsage
Here's a practical example of how to use the library:
import { serverSideAuthenticated } from "@lineuxyz/next-auth-server-side";
export const getServerSideProps = serverSideAuthenticated(
async () => {
const response = await axios.get('/your-path')
return { props: { yourData: response } };
},
{
cookieName: "your-cookie-name",
// Other configuration options...
}
);Configuration Properties
| Property Name | Required | Description |
|---|---|---|
| cookieName | Yes | Name of the cookie that contains the token. |
| tokenFailed | No | Configuration for redirection when token retrieval fails. Details below. |
| requestFailed | No | Configuration for redirection when a request fails. Details below. |
tokenFailed & requestFailed Details
| Property Name | Default | Description |
|---|---|---|
| destinationUrl | / | Redirect URL. |
| isPermanent | false | Whether the redirection is permanent. |
| statusCode | - | HTTP status code for redirection (e.g., `302`). |
Contributing
We welcome contributions from developers! If you'd like to contribute, here's how you can get started:
- Fork the Repository: Fork the
@lineuxyz/next-auth-server-siderepository to your own GitHub account. - Clone the Forked Repository: Clone your fork locally on your machine.
- Install Dependencies: Navigate to the project root and run
npm installoryarn add. - Make Your Changes: Implement your features or fixes.
- Test Your Changes: Ensure that your changes do not introduce any bugs.
- Submit a Pull Request: Once done, push your changes to your fork on GitHub and submit a pull request.