How to create and use aliases in NextJS

Oscar de la Hera Gomez

<p>A flower that represents NextJS with the text "Create and Use Aliases” beneath it.</p>
<p></p>

A guide for setting up, creating and using aliases in NextJS.

Please note that Aliases come setup out of the box when creating a new NextJS project.

Step One: Update the tsconfig.json

A screenshot of VSCode highlighting the changes we made to the tsconfig.json file. Code snippet available below.

Update the tsconfig to include a baseUrl ("./src") and any relevant paths.

Step Two: Implement

A screenshot of NextJS showing how the Alias works.

Import a new file or update the import of an existing file to use the alias.

Step Three: Test

A screenshot of the app running in chrome showing the component rendered as expected.

Run the app locally or deploy to Vercel to confirm changes.

Looking to learn more about NextJS, ReactJS or web development?

Search our blog to find educational content on NextJS, ReactJS and web development.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details