<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: musinda kadhuwa</title>
    <description>The latest articles on DEV Community by musinda kadhuwa (@jkadhuwa).</description>
    <link>https://dev.to/jkadhuwa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F654704%2Fbd6d72eb-1fd9-4aa3-b889-a58c0ae5aa1b.JPG</url>
      <title>DEV Community: musinda kadhuwa</title>
      <link>https://dev.to/jkadhuwa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jkadhuwa"/>
    <language>en</language>
    <item>
      <title>Getting Started with Next.js, Storybook, Tailwind CSS, and Playwright: A Beginner's Guide.</title>
      <dc:creator>musinda kadhuwa</dc:creator>
      <pubDate>Thu, 30 Mar 2023 08:53:56 +0000</pubDate>
      <link>https://dev.to/jkadhuwa/getting-started-with-nextjs-storybook-tailwind-css-and-playwright-a-beginners-guide-34j8</link>
      <guid>https://dev.to/jkadhuwa/getting-started-with-nextjs-storybook-tailwind-css-and-playwright-a-beginners-guide-34j8</guid>
      <description>&lt;p&gt;This is a beginner's guide to the integration of these wonderful technologies. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setup a Next.js project with typescript&lt;/li&gt;
&lt;li&gt;Configure Tailwind CSS&lt;/li&gt;
&lt;li&gt;Configure Storybook&lt;/li&gt;
&lt;li&gt;Configure Playwright&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Node.js installed in you machine&lt;/li&gt;
&lt;li&gt;Package management tool like pnpm, yarn or npm&lt;/li&gt;
&lt;li&gt;Code editor like vs code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Next.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next.js is a popular React-based framework that makes it easier to build server-side rendered applications. It provides routing out of the box, improved SEO, automatic code splitting(diving your code into smaller chunks that can be loaded on demand,hence reducing the load time), image optimization,built-in CSS support and most importantly Hot Module replacement which helps developers see changes immediately without refreshing the page.&lt;/p&gt;

&lt;p&gt;On your command line run one the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn create next-app --typescript 
or
pnpm create next-app --typescript
or
npx create-next-app@latest --typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the prompt by passing the necessary info like app-name e.t.c. this will create a pre-configured next.js application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tailwind CSS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a utility-first CSS framework that helps developers create responsive and customizable UI's quickly and efficiently. &lt;br&gt;
Unlike traditional CSS framework like Bootstrap or Material-UI with pre-defined components, Tailwind CSS provides a low-level utility classes that can be used to style HTML elements.&lt;br&gt;
There are several ways to add Tailwind CSS to our project as provided in the &lt;a href="https://tailwindcss.com/docs/installation/using-postcss"&gt;offical docs&lt;/a&gt;, so we will be using the PostCSS.&lt;/p&gt;

&lt;p&gt;In the directory containing out next.js project run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add postcss autoprefixer tailwindcss -D
npx tailwindcss init -p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the second command will create two configuration files i.e  &lt;code&gt;tailwind.config.js&lt;/code&gt; and &lt;code&gt;postcss.config.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;tailwind.config.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  content: ["./src/**/*.{ts,tsx, js, jsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;postcss.config.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have to add th tailwind directives to our main css file. For our project global.css located in the styles directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@tailwind base;
@tailwind components;
@tailwind utilities;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you can start using tailwind in your project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storybook&lt;/strong&gt;&lt;br&gt;
Storybook is a tool for building and testing isolated UI components in a development environment allowing developers to showcase components visually hence making it easier to collaborate and maintain a consistent design system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx storybook@next init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to update &lt;code&gt;.storybook/main.js&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// .storybook/main.js
export default {
  addons: ['@storybook/addon-essentials'],
  framework: {
    name: '@storybook/nextjs',

    options: {},
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Playwright&lt;/strong&gt;&lt;br&gt;
Playwright is an open-source testing framework that helps you create and run automated end-to-end tests hence deploy your applications with confidence.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;yarn add @playwright/test -D&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Add Playwright to the &lt;code&gt;package.json&lt;/code&gt; script field.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "dev": "next dev",
  "build": "next build",
  "start": "next start",
  "test:e2e": "playwright test",
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://nextjs.org/docs/getting-started"&gt;Next.js Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://tailwindcss.com/docs/installation"&gt;Tailwind CSS Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/@storybook/nextjs?activeTab=readme"&gt;Storybook/next docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/@playwright/test"&gt;Playwright&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>typescript</category>
      <category>tailwindcss</category>
    </item>
  </channel>
</rss>
