DEV Community

Cover image for NextJS portfolio setting up - part 2
Chris Bongers
Chris Bongers

Posted on • Originally published at daily-dev-tips.com

NextJS portfolio setting up - part 2

In the last part we had an overall look at what we would build, and I even gave you some homework to find an excellent design and analyze it into building blocks.

This article will look at setting up the project and installing all the dependencies we need.

Setting up the Next.js project

The basic Next.js set up is quite forward these days, so let's run through it.

First, open your terminal and run the following command to create a new Next.js project.

npx create-next-app
Enter fullscreen mode Exit fullscreen mode

Once done, it will install the project inside a folder whose name you picked in the CLI prompt.

Navigate to this folder (in my case, next-portfolio).

cd next-portfolio
Enter fullscreen mode Exit fullscreen mode

If you are eager to see it work, run npm run dev to start up the server.

However, we will look into adding Tailwind CSS. First, Tailwind is an easy way to style the application neatly.
You can also opt for regular CSS if you are unfamiliar with it.

First, install the needed dependencies:

npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
Enter fullscreen mode Exit fullscreen mode

After that, run the following command to initialize a tailwind config file.

npx tailwindcss init -p
Enter fullscreen mode Exit fullscreen mode

Open the project in your favorite editor and find the tailwind.config.js file.
Add the pages and components config into the content part like this:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    './pages/**/*.{js,ts,jsx,tsx}',
    './components/**/*.{js,ts,jsx,tsx}',
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};
Enter fullscreen mode Exit fullscreen mode

Then we have to modify the styles/global.css to include the Tailwind imports.

@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
Enter fullscreen mode Exit fullscreen mode

While we are at it, also remove some of the things we won't be needing:

  • styles/Home.module.css
  • pages/api

And let's modify our pages/index.js file to see if Tailwind is working.

import Head from 'next/head';

export default function Home() {
  return (
    <div>
      <Head>
        <title>NextJS Portfolio</title>
        <meta name='description' content='Generated by create next app' />
        <link rel='icon' href='/favicon.ico' />
      </Head>
      <main className='grid place-content-center min-h-screen'>
        <div className='max-w-xs rounded overflow-hidden shadow-lg my-2'>
          <div className='px-6 py-4'>
            <div className='font-bold text-xl mb-2'>Next + Tailwind โค๏ธ</div>
            <p className='text-grey-darker text-base'>
              Next and Tailwind CSS are a match made in heaven. Check out this
              article on how you can combine these two for your next app.
            </p>
          </div>
        </div>
      </main>
    </div>
  );
}
Enter fullscreen mode Exit fullscreen mode

Now run your app: npm run dev and visit http://localhost:3000/ to see it in action.

NextJS Tailwind set up

Alright, that's our setup for today!
We created the project and added Tailwind to it.

Keep an eye out for tomorrow's article, where we'll dive into layouts in Next.js.

You can find the code for today on GitHub.

Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Top comments (2)

Collapse
 
j471n profile image
Jatin Sharma

I am also making a blog on next.js portfolio. Well, it's more like how I made my portfolio from top to bottom. It should be out by next Sunday (i think). Btw It's a nice blog and Series as always โค๏ธ

Collapse
 
dailydevtips1 profile image
Chris Bongers

Nice!

Always good to give people some better understanding on how to set it up ๐Ÿ’–