- Open a terminal and run the following command:
git clone <REPO_URL. Get > cd <PROJECT_NAME>
Run the following command in the project directory to install all required dependencies:
npm install
- If the repository includes an
.env.example
file, use it as a reference:cp .env.example .env
- If not, create a new
.env
file:touch .env
- Add all the required environment variables with appropriate keys and values.
Follow the steps below to extract the necessary keys and secrets for the platforms mentioned in your .env
file:
- Steps to Get
CLOUDINARY_SECRET
,API_KEY
, andCLOUD_NAME
:- Log in to your Cloudinary account at cloudinary.com.
- Navigate to the Dashboard.
- Under "Account Details," find:
CLOUD_NAME
API_KEY
API_SECRET
(use asCLOUDINARY_SECRET
).
- Steps to Get
MONGO_URI
:- Log in to MongoDB Atlas.
- Go to Database Deployments and select your cluster.
- Click Connect > Connect Your Application.
- Copy the connection string (
mongodb+srv://...
) and replace<username>
and<password>
with your credentials.
- Steps to Get
NEXTAUTH_SECRET
:- Use any secure random string generator, such as OpenSSL:
openssl rand -base64 32
- Copy the generated string as your
NEXTAUTH_SECRET
.
- Use any secure random string generator, such as OpenSSL:
- Steps to Get
PAYPAL_CLIENT_ID
andPAYPAL_CLIENT_SECRET
:- Log in to your PayPal Developer Dashboard.
- Go to My Apps & Credentials > REST API Apps.
- Create or select an app.
- Copy the Client ID and Secret for the app.
- Steps to Get
STRIPE_SECRET_KEY
andSTRIPE_PUBLIC_KEY
:- Log in to Stripe Dashboard.
- Go to API Keys under the Developers section.
- Copy the Secret Key and Publishable Key.
- Set static values for
TAX_PRICE
andSHIPPING_PRICE
as per your requirements.
Once the .env
file is set up with all the required variables, start the development server:
npm run dev
Open your browser and visit:
http://localhost:3000
- Use
dotenv
in Development: Ensure your project supports.env
files (Next.js supports them by default). - Secure Keys in Production: Avoid committing
.env
files to your repository. Use deployment platforms like Vercel or AWS to securely manage secrets in their environment configuration settings.
For large projects with multiple contributors, use tools like Doppler or Vault to manage secrets securely.