Utils
Introduction
A utility library designed to simplify reusability of utils functions in projects, providing commonly used utility functions, helpers and types.
Installation
To use @phpcreation/frontend-utils-react-nextjs-bundle in your project, follow these steps:
Open a terminal in your project root
Create a Github Personnal Access Token
How to create a Github PAT :
Create a Github Personal Access TokenLogin to NPM registry
npm login --scope=@phpcreation --auth-type=legacy --registry=https://npm.pkg.github.com- username: your github username in lowercase
- password: The PAT you just created
Install the Package
npm install @phpcreation/frontend-utils-react-nextjs-bundleSetup
Environment Variables
Follow these steps to manage environment variables correctly :
Environment Variables Management.env.local
These variables should be sent to the secrets of the deployed app. and not committed to version control.
# Security
SECURITY_JWT_SECRET= # The secret key to encrypt and decrypt JWT tokens
SECURITY_CSRF_SECRET= # The secret key to encrypt and decrypt CSRF tokensUsage
Step 1: Importing Utilities
Example: Import a Utility Function
import { getFQCN } from "@phpcreation/frontend-utils-react-nextjs-bundle/utils/functions";
const fqcn_bui = {
Bundle: "homeBundle",
Unit: "landing",
Interface: "page",
};
const id = getFQCN(fqcn_bui, "button");
console.log(id); // Output: pfqcn_phprconfig_homeBundle_landing_page_buttonCommon Issues
Common IssuesLast updated on