- Root layout
/app/layout.js
with an example navbar - Example layout for other pages
/about/layout.js
- routes
/about
,/resources
- nested routes
/about/contact
- dynamic routes
/resources/[resource]
- regular navigation
/app/navbar.js
withLink
- relative path navigation
/about
withuseRouter
andusePathName
/app/api
has all the APIs used by the application/app/api/about/route.js
shows how to use secrets for external APIs.env
file to store secrets, used in the frontend and backend to prevent revealing private info
- add new files titled
layout.js
in the route - main layout is
app/layout.js
to change the structuring of the page - using a layout in
/about/layout.js
to add components
- add
'use client';
if there seems to be a rendering issue - navigate to new pages using
Link
- add a new folder into
src/app
calling it the page route you want- i.e. new route of
www.example.com/experiences
has a folder ofapp/experiences
and the code for the page is inapp/experiences/page.js
- i.e. new route of
- add components into the folder
- nest routes by adding additional folders
- i.e. subroute
www.example.com/experiences/business
has a folder ofapp/experiences/business
- i.e. subroute
- create dynamic routes by adding a brackets around a route name in a folder
- i.e.
/resources/[resource]
allows you to pass parameters through the url which can be obtained by the following page
- i.e.
- add
.env
file and make sure it is already added to.gitignore
- create a new folder under
/app/api
with the new route you want to create - add a
route.js
file under the folder to create an API handler for GET, POST, etc.
- Clone the repo to your local setup by running
git clone https://github.com/lablueprint/bp-nextjs-starter-code.git
in your terminal in the directory you'd like. - Enter the new folder via
cd bp-nextjs-starter-code
.
- Go to https://github.com/.
- Log in to your GitHub account.
- Click the "+" sign in the upper right corner and select "New repository" from the dropdown menu.
- Fill in the repository name, description, and other details, then click the "Create repository" button.
-
From the folder with the starter code, remove the connection to the initial repository (the remote named
origin
) by runninggit remote remove origin
. -
Run
git remote add origin new_repository_url
to add the URL of your new GitHub repository as the remote repo. Replacenew_repository_url
with the URL of the new repository you created. For example:git remote add origin https://github.com/yourusername/my-nextjs-project.git
.
- Make changes to your code in the local repository.
- Add all changed files to the stage using
git add *
. - Commit your changes using
git commit -m [message]
. Add a message to commit successfully. - Push your code to the new repository on GitHub by running
git push -u origin main
.
-
Install the necessary modules to run the application by running
npm install
. -
To run your app locally, run
npm run dev
in terminal in the directory with all the code.