<?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: Swahilipot Developers</title>
    <description>The latest articles on DEV Community by Swahilipot Developers (@swahilipotdevs).</description>
    <link>https://dev.to/swahilipotdevs</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%2Forganization%2Fprofile_image%2F8888%2F6166e039-a9c8-44fb-98e3-97a96298b270.png</url>
      <title>DEV Community: Swahilipot Developers</title>
      <link>https://dev.to/swahilipotdevs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swahilipotdevs"/>
    <language>en</language>
    <item>
      <title>Technical Overview of Next.js.</title>
      <dc:creator>Milka Mutinda</dc:creator>
      <pubDate>Tue, 17 Sep 2024 15:44:33 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/technical-overview-of-lessons-learnt-12ol</link>
      <guid>https://dev.to/swahilipotdevs/technical-overview-of-lessons-learnt-12ol</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Lessons learned in nextjs:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
**&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating the new project.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Key in the following command in the terminal .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then to create an app, enter the following command in the terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enter the following command still in the terminal to create the app in the desired folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest nextjs-dashboard 
      example "https://github.com/vercel/next- 
      learn/tree/main/dashboard/starter-example" - 
      -use-pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Running development server.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To install the project packages, run the below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Followed by the following command to start the development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Adding styles.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To add global styles in your application, navigate to layout.tsx file under app folder and key import the global.css file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import '@/app/ui/global.css';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Creating a Home Page.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create an attractive home page, elements like fonts and images are crucial. We will start by adding fonts in the project. By the use of next/font module, Next.js automatically optimizes in the application and downloads the font files at build time to host them with the other static assets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; _import { Inter, Lusitana } from 'next/font/google';_

_export const inter = Inter({ subsets: ['latin'] });_

export const lusitana = Lusitana({
    weight: ['400', '700'],
    subsets: ['latin'],
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add the desktop image, we use the  component. In the /app/page.tsx file, import the component from next/image and then add the image under the comment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import AcmeLogo from '@/app/ui/acme-logo';
import { ArrowRightIcon } from '@heroicons/react/24/outline';
import Link from 'next/link';
import { lusitana} from '@/app/ui/fonts';
_import Image from 'next/image';_
//..........    
        _&amp;lt;Image
        src="/hero-mobile.png"
        width={560}
        height={620}
        className="block md:hidden"
        alt="Screenshot of the dashboard project showing mobile version"
      /&amp;gt;_

        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Nesting Routes.&lt;/strong&gt;&lt;br&gt;
Create folders that are used to nest routes. For example, create folders under the app folder, like a dashboard and invoices that map to a URL to showcase your app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Navigating through Pages.&lt;/strong&gt;&lt;br&gt;
To navigate through a page, you need to use  component to link between pages in the application. To use this  component, go to /app/ui/dashboard/nav-links.tsx, and import the Link component from next/link. Replace &lt;a&gt; with .&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/...
import {
  UserGroupIcon,
  HomeIcon,
  DocumentDuplicateIcon,
} from '@heroicons/react/24/outline';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import clsx from 'clsx';
/...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Setting Up Database.&lt;/strong&gt;**&lt;/p&gt;

&lt;p&gt;Here, you will start by pushing your repository to Github for ease in setting up the database and deploying. Set up a vercel account and import your already created folder containing your app then deploy.&lt;/p&gt;

&lt;p&gt;Afterwards, connect store, create new, postgres then continue. Once you are done with that, go to .env.local tab, click show secret and copy snippet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POSTGRES_URL="postgres://default:W95RsBPGcbeU@ep-cold-bar-a457mttq-pooler.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require"
POSTGRES_PRISMA_URL="postgres://default:W95RsBPGcbeU@ep-cold-bar-a457mttq-pooler.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require&amp;amp;pgbouncer=true&amp;amp;connect_timeout=15"
POSTGRES_URL_NO_SSL="postgres://default:W95RsBPGcbeU@ep-cold-bar-a457mttq-pooler.us-east-1.aws.neon.tech:5432/verceldb"
POSTGRES_URL_NON_POOLING="postgres://default:W95RsBPGcbeU@ep-cold-bar-a457mttq.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require"
POSTGRES_USER="default"
POSTGRES_HOST="ep-cold-bar-a457mttq-pooler.us-east-1.aws.neon.tech"
POSTGRES_PASSWORD="W95RsBPGcbeU"
POSTGRES_DATABASE="verceldb"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Seeding The Database.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The database is seeded inside of /app, in a folder called seed. Make sure to uncomment the file. The folder contains a Next.js Route Handler, called route.ts, that will be used to seed your database.&lt;br&gt;
Ensure your local development server is running with pnpm run dev and navigate to your localhost. Afterwards, a confirmation message will appear to show a success.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fetching Data For The Dashboard Overview Page.&lt;/strong&gt;&lt;br&gt;
There are several ways of fetching data from the database, like using server components where in next.js we use react server components.&lt;br&gt;
There is also using SQL where you'll write dataabase queries using vercel postgres created previously and SQL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Card } from '@/app/ui/dashboard/cards';
import RevenueChart from '@/app/ui/dashboard/revenue-chart';
import LatestInvoices from '@/app/ui/dashboard/latest-invoices';
import { lusitana } from '@/app/ui/fonts';

export default async function Page() {
  return (
    &amp;lt;main&amp;gt;
      &amp;lt;h1 className={`${lusitana.className} mb-4 text-xl md:text-2xl`}&amp;gt;
        Dashboard
      &amp;lt;/h1&amp;gt;
      &amp;lt;div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4"&amp;gt;
        {/* &amp;lt;Card title="Collected" value={totalPaidInvoices} type="collected" /&amp;gt; */}
        {/* &amp;lt;Card title="Pending" value={totalPendingInvoices} type="pending" /&amp;gt; */}
        {/* &amp;lt;Card title="Total Invoices" value={numberOfInvoices} type="invoices" /&amp;gt; */}
        {/* &amp;lt;Card
          title="Total Customers"
          value={numberOfCustomers}
          type="customers"
        /&amp;gt; */}
      &amp;lt;/div&amp;gt;
      &amp;lt;div className="mt-6 grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8"&amp;gt;
        {/* &amp;lt;RevenueChart revenue={revenue}  /&amp;gt; */}
        {/* &amp;lt;LatestInvoices latestInvoices={latestInvoices} /&amp;gt; */}
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Handling Errors.&lt;/strong&gt;&lt;br&gt;
To handle errors in your code, you have to add JavaScript's try/catch statements inside your server actions /app/lib/actions.ts, to allow handling of errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessibility.&lt;/strong&gt;&lt;br&gt;
Accessibility is crucial for making web applications usable for everyone. Next.js, being a React-based framework, offers a range of techniques and tools to ensure that your application is accessible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding Metadata.&lt;/strong&gt;&lt;br&gt;
Adding metadata to your Next.js application is essential for several reasons, primarily focused on improving SEO, accessibility, and sharing your web content on social media. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Nextjs-Dashboard Project .</title>
      <dc:creator>Tribal Chief</dc:creator>
      <pubDate>Tue, 17 Sep 2024 11:21:36 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/nextjs-dashboard-project--2h91</link>
      <guid>https://dev.to/swahilipotdevs/nextjs-dashboard-project--2h91</guid>
      <description>&lt;p&gt;In the past two weeks, I have embarked on an intensive development journey, creating a sophisticated dashboard application using the Next.js framework along with Typescript, React, and various other technologies. This article delves into the specific tasks I tackled, the technologies I employed, and the insights I gained.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;here is a look at the dashboard app&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo93dkj0adaezcn19fqot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo93dkj0adaezcn19fqot.png" alt="the image of the financial dashboard" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl0xemg9qnu1wfu1vffny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl0xemg9qnu1wfu1vffny.png" alt="Image description" width="800" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxv1c4sfeuccx5ywzv02p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxv1c4sfeuccx5ywzv02p.png" alt="Image description" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  setting up the project
&lt;/h2&gt;

&lt;p&gt;i used pnpm package manager as it is fast than npm or yarn  i installed it globally bz running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;creating a nextjs app i used this command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example" --use-pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command uses create-next-app, a Command Line Interface (CLI) tool that sets up a Next.js application. In the command above, it  also using the --example flag with the starter example for this project &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;em&gt;1. Global Styles and Tailwind CSS&lt;/em&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;One of the initial steps in my project was to set up global styles using Tailwind CSS. Tailwind CSS is a utility-first CSS framework that facilitates rapid UI development by allowing developers to apply pre-defined classes directly in the markup. I integrated Tailwind CSS by configuring the tailwind.config.js file and incorporating the necessary CSS imports into the global stylesheet. This setup streamlined the design process and ensured consistent styling across the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding Global Styles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To apply global styles across the application, i used a global CSS file. In a Next.js project, i import this CSS file in the root layout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// /app/layout.tsx

import '@/app/ui/global.css';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    &amp;lt;html lang="en"&amp;gt;
      &amp;lt;body&amp;gt;{children}&amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach ensures that the styles defined in global.css are applied throughout your app.&lt;/p&gt;

&lt;p&gt;and in   &lt;code&gt;/* /app/ui/global.css */&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`/* /app/ui/global.css */`
@tailwind base;
@tailwind components;
@tailwind utilities;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These directives set up Tailwind's base styles, components, and utility classes, providing a foundation for the design&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;&lt;strong&gt;2. CSS Modules&lt;/strong&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;For more component-specific styling, I employed CSS Modules. CSS Modules offer a scoped approach to CSS, ensuring that styles are applied only to the component they are defined in. This modularity prevents style conflicts and enhances maintainability. I utilized CSS Modules by creating .module.css files and importing them into React components, thereby achieving encapsulated and reusable styles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conditionally Adding Class Names with &lt;code&gt;clsx&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For dynamic styling, i used the clsx utility package. This package helps conditionally apply class names based on certain conditions.&lt;/p&gt;

&lt;p&gt;for instance you will first need to install &lt;code&gt;clsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install clsx

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then use in the component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import clsx from 'clsx';

export default function Button({ isActive }: { isActive: boolean }) {
  return (
    &amp;lt;button className={clsx('p-2 rounded', { 'bg-blue-500': isActive, 'bg-gray-500': !isActive })}&amp;gt;
      Click me
    &amp;lt;/button&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the button's background color changes based on the isActive prop.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. Setting Up and Seeding a PostgreSQL Database for Your Next.js Project&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To effectively manage data in your Next.js application, setting up and seeding a PostgreSQL database is essential. This guide will walk you through the process of configuring a PostgreSQL database using Vercel's PostgreSQL service and seeding it with initial data. By the end of this guide, you'll have a fully functional database ready for your Next.js dashboard application.&lt;/p&gt;

&lt;p&gt;Table of Contents :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a GitHub Repository&lt;/li&gt;
&lt;li&gt;Create a Vercel Account and Deploy Your Project&lt;/li&gt;
&lt;li&gt;Create and Link Your PostgreSQL Database&lt;/li&gt;
&lt;li&gt;Seed Your Database&lt;/li&gt;
&lt;li&gt;Exploring and Querying Your Database
-Troubleshooting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a GitHub Repository
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;If you haven’t set up a repository yet, follow this  &lt;a href="https://docs.github.com/en/get-started/quickstart/create-a-repo" rel="noopener noreferrer"&gt;GitHub guide&lt;/a&gt;.&lt;br&gt;
to get started. For a simplified workflow, consider using the GitHub Desktop App.&lt;/p&gt;

&lt;p&gt;Note: You can use other Git providers like GitLab or Bitbucket if preferred.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;
&lt;h2&gt;
  
  
  Create a Vercel Account and Deploy Your Project
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;** Sign Up for Vercel:**&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Visit vercel.com/signup to create an account.
    Choose the free "Hobby" plan.
    Select "Continue with GitHub" to connect your GitHub and              Vercel accounts.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;** Import and Deploy Your Project:**&lt;br&gt;
        After signing up, you'll be redirected to the Vercel dashboard.&lt;br&gt;
        Click "Import Project" and select your GitHub repository.&lt;br&gt;
        Name your project and click "Deploy."&lt;/p&gt;

&lt;p&gt;boooom!!! there you go the project is now deployed. Vercel will automatically redeploy the application with each push to the main branch and provide instant previews for pull requests.&lt;/p&gt;

&lt;p&gt;Create and Link Your PostgreSQL Database&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Access Your Vercel Dashboard:&lt;br&gt;
    Navigate to your project’s dashboard on Vercel.&lt;br&gt;
    Click "Continue to Dashboard" and select the "Storage" tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a New Database:&lt;br&gt;
    Click "Connect Store" → "Create New" → "Postgres" → "Continue."&lt;br&gt;
    Accept the terms, name your database, and set the region to Washington D.C (iad1), which is the default for new Vercel projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy Database Secrets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the .env.local tab in Vercel, click "Show secret," and copy the snippet.

&lt;ul&gt;
&lt;li&gt;Rename the .env.example file in your project to .env and paste the copied contents from Vercel.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Important: Ensure .env is listed in your .gitignore file to prevent exposing your database secrets in version control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install the Vercel Postgres SDK:&lt;/p&gt;

&lt;p&gt;Run the following command to install the Vercel Postgres SDK:&lt;br&gt;
&lt;/p&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm i @vercel/postgres

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Seed Your Database&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Seeding your database involves populating it with initial data to test your application.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Prepare the Seed Script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inside the &lt;code&gt;/app&lt;/code&gt; directory, locate and uncomment the &lt;code&gt;seed&lt;/code&gt; folder. This folder contains &lt;code&gt;route.ts&lt;/code&gt;, a Next.js Route Handler used to seed your database.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the Seed Script:&lt;br&gt;
    Ensure your local development server is running with:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm run dev

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after that you can Navigate to &lt;code&gt;http://localhost:3000/seed&lt;/code&gt; in your browser. You should see a message "Database seeded successfully."&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;4. Adding Authentication to Your Next.js Dashboard Application&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I integrated authentication functionalities, including login and logout features. This process involved updating the login form, implementing secure authentication mechanisms, and ensuring proper session management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;here i will take you through :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting Up NextAuth.js&lt;/li&gt;
&lt;li&gt;Protecting Routes with Middleware&lt;/li&gt;
&lt;li&gt;Implementing Password Hashing&lt;/li&gt;
&lt;li&gt;Adding Authentication Providers&lt;/li&gt;
&lt;li&gt;Updating the Login Form&lt;/li&gt;
&lt;li&gt;Adding Logout Functionality&lt;/li&gt;
&lt;li&gt;Testing Your Implementation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Setting Up NextAuth.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To add authentication to the application,i used NextAuth.js. This library simplifies session management, sign-ins, and sign-outs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install NextAuth.js&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Run the following command to install the beta version compatible with Next.js 14:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm i next-auth@beta

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Generate a Secret Key&lt;/p&gt;

&lt;p&gt;Generate a secret key for encrypting cookies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl rand -base64 32

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this key to your .env file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AUTH_SECRET=your-secret-key

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Configure NextAuth.js&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create an auth.config.ts file in the root of your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// auth.config.ts

import type { NextAuthConfig } from 'next-auth';

export const authConfig = {
  pages: {
    signIn: '/login',
  },
} satisfies NextAuthConfig;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration sets the custom sign-in page route.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protecting Routes with Middleware&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To ensure only authenticated users can access specific routes, use Next.js Middleware.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create Middleware&lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;middleware.ts&lt;/code&gt; file in the root of your project:&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// middleware.ts

import NextAuth from 'next-auth';
import { authConfig } from './auth.config';

export default NextAuth(authConfig).auth;

export const config = {
  matcher: ['/((?!api|_next/static|_next/image|.*\\.png$).*)'],
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup ensures that Middleware runs on the specified paths, protecting the routes by checking authentication before rendering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementing Password Hashing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hashing passwords adds an extra layer of security by transforming passwords into a fixed-length string.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create an Authentication Module&lt;/p&gt;

&lt;p&gt;Create an &lt;code&gt;auth.ts&lt;/code&gt; file for handling authentication logic:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;// auth.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import NextAuth from 'next-auth';
import { authConfig } from './auth.config';
import Credentials from 'next-auth/providers/credentials';
import bcrypt from 'bcrypt';
import { sql } from '@vercel/postgres';
import type { User } from '@/app/lib/definitions';

async function getUser(email: string): Promise&amp;lt;User | undefined&amp;gt; {
  try {
    const user = await sql&amp;lt;User&amp;gt;`SELECT * FROM users WHERE email=${email}`;
    return user.rows[0];
  } catch (error) {
    console.error('Failed to fetch user:', error);
    throw new Error('Failed to fetch user.');
  }
}

export const { auth, signIn, signOut } = NextAuth({
  ...authConfig,
  providers: [
    Credentials({
      async authorize(credentials) {
        const parsedCredentials = z
          .object({ email: z.string().email(), password: z.string().min(6) })
          .safeParse(credentials);

        if (parsedCredentials.success) {
          const { email, password } = parsedCredentials.data;
          const user = await getUser(email);
          if (user &amp;amp;&amp;amp; await bcrypt.compare(password, user.password)) {
            return user;
          }
        }
        return null;
      },
    }),
  ],
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration sets up the Credentials provider and checks if the entered password matches the hashed password stored in the database&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding Authentication Providers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Credentials provider allows users to log in with a username and password. While other providers like Google or GitHub are available, i will focus on Credentials for simplicity.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Update the Authentication Configuration&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;// auth.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import NextAuth from 'next-auth';
import Credentials from 'next-auth/providers/credentials';
import { authConfig } from './auth.config';

export const { auth, signIn, signOut } = NextAuth({
  ...authConfig,
  providers: [
    Credentials({
      // Configuration for Credentials provider
    }),
  ],
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Updating the Login Form&lt;/p&gt;

&lt;p&gt;To connect the authentication logic with the login form, i use React’s useActionState to handle form submissions and display errors.&lt;/p&gt;

&lt;p&gt;1.Create the Login Form&lt;/p&gt;

&lt;p&gt;&lt;code&gt;// app/ui/login-form.tsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use client';

import { lusitana } from '@/app/ui/fonts';
import { AtSymbolIcon, KeyIcon, ExclamationCircleIcon } from '@heroicons/react/24/outline';
import { ArrowRightIcon } from '@heroicons/react/20/solid';
import { Button } from '@/app/ui/button';
import { useActionState } from 'react';
import { authenticate } from '@/app/lib/actions';

export default function LoginForm() {
  const [errorMessage, formAction, isPending] = useActionState(authenticate, undefined);

  return (
    &amp;lt;form action={formAction} className="space-y-3"&amp;gt;
      &amp;lt;div className="flex-1 rounded-lg bg-gray-50 px-6 pb-4 pt-8"&amp;gt;
        &amp;lt;h1 className={`${lusitana.className} mb-3 text-2xl`}&amp;gt;Please log in to continue.&amp;lt;/h1&amp;gt;
        &amp;lt;div className="w-full"&amp;gt;
          &amp;lt;div&amp;gt;
            &amp;lt;label className="mb-3 mt-5 block text-xs font-medium text-gray-900" htmlFor="email"&amp;gt;Email&amp;lt;/label&amp;gt;
            &amp;lt;div className="relative"&amp;gt;
              &amp;lt;input
                className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500"
                id="email"
                type="email"
                name="email"
                placeholder="Enter your email address"
                required
              /&amp;gt;
              &amp;lt;AtSymbolIcon className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 text-gray-500 peer-focus:text-gray-900" /&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className="mt-4"&amp;gt;
            &amp;lt;label className="mb-3 mt-5 block text-xs font-medium text-gray-900" htmlFor="password"&amp;gt;Password&amp;lt;/label&amp;gt;
            &amp;lt;div className="relative"&amp;gt;
              &amp;lt;input
                className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500"
                id="password"
                type="password"
                name="password"
                placeholder="Enter password"
                required
                minLength={6}
              /&amp;gt;
              &amp;lt;KeyIcon className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 text-gray-500 peer-focus:text-gray-900" /&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;Button className="mt-4 w-full" aria-disabled={isPending}&amp;gt;
          Log in &amp;lt;ArrowRightIcon className="ml-auto h-5 w-5 text-gray-50" /&amp;gt;
        &amp;lt;/Button&amp;gt;
        &amp;lt;div className="flex h-8 items-end space-x-1" aria-live="polite" aria-atomic="true"&amp;gt;
          {errorMessage &amp;amp;&amp;amp; (
            &amp;lt;&amp;gt;
              &amp;lt;ExclamationCircleIcon className="h-5 w-5 text-red-500" /&amp;gt;
              &amp;lt;p className="text-sm text-red-500"&amp;gt;{errorMessage}&amp;lt;/p&amp;gt;
            &amp;lt;/&amp;gt;
          )}
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This form connects to the authenticate action, displays pending states, and handles error messages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding Logout Functionality&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Adding a logout button to the side navigation to enable users to sign out.&lt;/p&gt;

&lt;p&gt;1.Update the SideNav Component&lt;/p&gt;

&lt;p&gt;&lt;code&gt;// ui/dashboard/sidenav.tsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import Link from 'next/link';
import NavLinks from '@/app/ui/dashboard/nav-links';
import AcmeLogo from '@/app/ui/acme-logo';
import { PowerIcon } from '@heroicons/react/24/outline';
import { signOut } from '@/auth';

export default function SideNav() {
  return (
    &amp;lt;div className="flex h-full flex-col px-3 py-4 md:px-2"&amp;gt;
      &amp;lt;div className="flex grow flex-row justify-between space-x-2 md:flex-col md:space-x-0 md:space-y-2"&amp;gt;
        &amp;lt;NavLinks /&amp;gt;
        &amp;lt;div className="hidden h-auto w-full grow rounded-md bg-gray-50 md:block"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;form
          action={async () =&amp;gt; {
            'use server';
            await signOut();
          }}
        &amp;gt;
          &amp;lt;button className="flex h-[48px] grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 text-sm font-medium hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3"&amp;gt;
            &amp;lt;PowerIcon className="w-6" /&amp;gt;
            &amp;lt;div className="hidden md:block"&amp;gt;Sign Out&amp;lt;/div&amp;gt;
          &amp;lt;/button&amp;gt;
        &amp;lt;/form&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This button calls the &lt;code&gt;signOut&lt;/code&gt; function from &lt;code&gt;auth.ts&lt;/code&gt; to log the user out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing the Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You should now be able to log in and out of the application using the credentials:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Email: user@nextmail.com
Password: 123456
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;5. Adding Metadata to the Next.js Application&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is Metadata?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Metadata provides additional details about a webpage that are not visible to users but are crucial for search engines and social media platforms. It resides in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of your HTML document and helps these systems understand and categorize your content more effectively.&lt;/p&gt;

&lt;p&gt;To improve SEO and enhance social media presence, I incorporated metadata into the application. Metadata, embedded within the &lt;/p&gt; element of HTML, provides search engines and social media platforms with additional information about the page. This included adding Open Graph tags to optimize link previews on social media.

&lt;p&gt;&lt;strong&gt;Adding Metadata in Next.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next.js provides a Metadata API that allows you to configure metadata in a flexible and organized manner. You can add metadata either through configuration files or dynamically within your components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Config-Based Metadata&lt;/strong&gt;&lt;br&gt;
 define static metadata in your layout.js or page.js files. Here’s how you can set up basic metadata:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Root Layout Metadata
In the root &lt;code&gt;layout.tsx&lt;/code&gt; file, define a metadata object:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;// app/layout.tsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Metadata } from 'next';

export const metadata: Metadata = {
  title: 'Acme Dashboard',
  description: 'The official Next.js Course Dashboard, built with App Router.',
  metadataBase: new URL('https://next-learn-dashboard.vercel.sh'),
};

export default function RootLayout() {
  // ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This metadata will be applied globally to all pages that use this layout.&lt;/p&gt;

&lt;p&gt;2.Page-Specific Metadata&lt;/p&gt;

&lt;p&gt;mmh, so To override or add metadata specific to a page, define the metadata object in the page file:&lt;br&gt;
&lt;code&gt;// app/dashboard/invoices/page.tsx&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Metadata } from 'next';

export const metadata: Metadata = {
  title: 'Invoices | Acme Dashboard',
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This page-level metadata will override the global metadata for this specific page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Page Titles with Templates&lt;/strong&gt;&lt;br&gt;
To avoid repetitive metadata and manage dynamic titles more efficiently, i usedt the &lt;code&gt;title.template&lt;/code&gt; field:&lt;/p&gt;

&lt;p&gt;yeey !!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set Up a Template in the Root Layout
&lt;code&gt;// app/layout.tsx&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Metadata } from 'next';

export const metadata: Metadata = {
  title: {
    template: '%s | Acme Dashboard',
    default: 'Acme Dashboard',
  },
  description: 'The official Next.js Learn Dashboard built with App Router.',
  metadataBase: new URL('https://next-learn-dashboard.vercel.sh'),
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The %s placeholder will be replaced with the page-specific title.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use the Template in a Page
&lt;code&gt;// app/dashboard/invoices/page.tsx&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export const metadata: Metadata = {
  title: 'Invoices',
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup results in a page title like "Invoices | Acme Dashboard."&lt;/p&gt;

&lt;p&gt;The past two weeks have been a period of significant learning and development. By employing a range of technologies and best practices, I have built a robust and efficient Next.js dashboard application. From optimizing performance to implementing secure data handling, each task has contributed to a comprehensive and scalable solution. This project not only enhanced my technical skills but also provided practical experience in building modern web applications.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setting Up Django and Building a Poll App: My Last Two Weeks of Work</title>
      <dc:creator>Ashley Obano</dc:creator>
      <pubDate>Mon, 16 Sep 2024 19:13:12 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/setting-up-django-and-building-a-poll-app-my-last-two-weeks-of-work-16jl</link>
      <guid>https://dev.to/swahilipotdevs/setting-up-django-and-building-a-poll-app-my-last-two-weeks-of-work-16jl</guid>
      <description>&lt;p&gt;Over the past two weeks, I've been working on setting up Django from scratch and building a simple poll application. This article will walk you through everything I did, starting from installing Python and Django, setting up a virtual environment, creating a new project, and building a functional app called polls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Setting Up Python and Django&lt;/strong&gt;&lt;br&gt;
To begin, I made sure that Python was installed on my system. If you haven't installed it yet, you can download it from python.org.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install Python and Set Up a Virtual Environment&lt;/strong&gt;&lt;br&gt;
I wanted to keep my project dependencies isolated, so I used a virtual environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Install virtualenv if you don't have it
pip install virtualenv

# Create a virtual environment
virtualenv myenv

# Activate the environment
# On Windows:
myenv\Scripts\activate
# On macOS/Linux:
source myenv/bin/activate

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Install Django&lt;/strong&gt;&lt;br&gt;
Once the environment was activated, I installed Django.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install django

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I then confirmed the installation by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;django-admin --version

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Starting a New Django Project: mysite&lt;/strong&gt;&lt;br&gt;
Now, it was time to create my Django project. I decided to call it mysite.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;django-admin startproject mysite
cd mysite

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This created the basic structure for a Django project with settings and configurations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Creating a New Django App: polls&lt;/strong&gt;&lt;br&gt;
After setting up the project, I created a new app called polls, which would contain all the logic and views for my poll application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py startapp polls

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I added the new app to INSTALLED_APPS in mysite/settings.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSTALLED_APPS = [
    # other installed apps
    'polls',
]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Defining the Models&lt;/strong&gt;&lt;br&gt;
I started by defining two models: Question and Choice. A Question has a question text and a publication date, while a Choice has a reference to a Question and stores text along with a vote count.&lt;/p&gt;

&lt;p&gt;Here’s the models.py file in the polls app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# models.py
import datetime
from django.db import models
from django.contrib import admin
from django.utils import timezone

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def __str__(self):
        return self.question_text

    @admin.display(
        boolean=True,
        ordering='pub_date',
        description='Published recently?',
    )
    def was_published_recently(self):
        now = timezone.now()
        return now - datetime.timedelta(days=1) &amp;lt;= self.pub_date &amp;lt;= now

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

    def __str__(self):
        return self.choice_text

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Creating the Database and Running Migrations&lt;/strong&gt;&lt;br&gt;
Next, I created the database and applied migrations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py migrate

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I then created migration files for the polls app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py makemigrations polls
python manage.py migrate

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Writing Views for the Poll App&lt;/strong&gt;&lt;br&gt;
I wrote several views to handle displaying a list of questions, showing question details, and showing voting results. These views are class-based, using Django’s built-in generic views.&lt;br&gt;
Creating Views for Polls&lt;br&gt;
I then created the views that control how data is displayed to the user. I used Django's generic views to keep things simple.&lt;/p&gt;

&lt;p&gt;Here’s the views.py file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# views.py
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.views import generic
from django.utils import timezone
from .models import Question, Choice

class IndexView(generic.ListView):
    template_name = 'polls/index.html'
    context_object_name = 'latest_question_list'

    def get_queryset(self):
        """Return the last five published questions."""
        return Question.objects.order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
    model = Question
    template_name = 'polls/detail.html'

    def get_queryset(self):
        """Exclude questions that aren't published yet."""
        return Question.objects.filter(pub_date__lte=timezone.now())

class ResultsView(generic.DetailView):
    model = Question
    template_name = 'polls/results.html'

def vote(request, question_id):
    return HttpResponse(f"You're voting on question {question_id}.")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;IndexView: Displays a list of the latest questions.&lt;/li&gt;
&lt;li&gt;DetailView: Shows the details of a specific question and its choices.&lt;/li&gt;
&lt;li&gt;ResultsView: Displays the results of a poll after voting.
The vote() function handles the user's vote submission.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;7. Configuring URLs&lt;/strong&gt;&lt;br&gt;
I added URL patterns to the urls.py file in the polls app to link each view to a specific URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# urls.py
from django.urls import path
from . import views

app_name = 'polls'
urlpatterns = [
    path('', views.IndexView.as_view(), name='index'),
    path('&amp;lt;int:pk&amp;gt;/', views.DetailView.as_view(), name='detail'),
    path('&amp;lt;int:pk&amp;gt;/results/', views.ResultsView.as_view(), name='results'),
    path('&amp;lt;int:question_id&amp;gt;/vote/', views.vote, name='vote'),
]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8. Creating Templates for Views&lt;/strong&gt;&lt;br&gt;
Finally, I created HTML templates to display the questions and results. The templates are placed in the polls/templates/polls/ folder.&lt;/p&gt;

&lt;p&gt;index.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{% if latest_question_list %}
    &amp;lt;ul&amp;gt;
        {% for question in latest_question_list %}
            &amp;lt;li&amp;gt;&amp;lt;a href="{% url 'polls:detail' question.id %}"&amp;gt;{{ question.question_text }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
        {% endfor %}
    &amp;lt;/ul&amp;gt;
{% else %}
    &amp;lt;p&amp;gt;No polls are available.&amp;lt;/p&amp;gt;
{% endif %}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;detail.html&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;&amp;lt;form action="{% url 'polls:vote' question.id %}" method="post"&amp;gt;
    {% csrf_token %}
    &amp;lt;fieldset&amp;gt;
        &amp;lt;legend&amp;gt;&amp;lt;h1&amp;gt;{{ question.question_text }}&amp;lt;/h1&amp;gt;&amp;lt;/legend&amp;gt;
        {% if error_message %}&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;{{ error_message }}&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;{% endif %}
        {% for choice in question.choice_set.all %}
            &amp;lt;input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}"&amp;gt;
            &amp;lt;label for="choice{{ forloop.counter }}"&amp;gt;{{ choice.choice_text }}&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
        {% endfor %}
    &amp;lt;/fieldset&amp;gt;
    &amp;lt;input type="submit" value="Vote"&amp;gt;
&amp;lt;/form&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;result.html&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;&amp;lt;h1&amp;gt;{{ question.question_text }}&amp;lt;/h1&amp;gt;
&amp;lt;ul&amp;gt;
    {% for choice in question.choice_set.all %}
        &amp;lt;li&amp;gt;{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}&amp;lt;/li&amp;gt;
    {% endfor %}
&amp;lt;/ul&amp;gt;
&amp;lt;a href="{% url 'polls:detail' question.id %}"&amp;gt;Vote again?&amp;lt;/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Running the Application&lt;/strong&gt;&lt;br&gt;
To test the application, I ran the development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py runserver

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigating to &lt;a href="http://127.0.0.1:8000/polls/" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/polls/&lt;/a&gt; displayed the list of polls, and I could view details, vote, and see results.&lt;/p&gt;

&lt;p&gt;Over the past two weeks, I learned how to set up Django, create a project, and build a fully functioning poll app. It was fascinating to see how everything connects in Django, from models to views to templates. This has been a great experience, and I’m excited to learn more about Django's powerful features!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>python</category>
      <category>productivity</category>
    </item>
    <item>
      <title>NEXTJS GUIDELINE</title>
      <dc:creator>Mumina</dc:creator>
      <pubDate>Mon, 16 Sep 2024 14:35:57 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/nextjs-article-21md</link>
      <guid>https://dev.to/swahilipotdevs/nextjs-article-21md</guid>
      <description>&lt;p&gt;Next.js has quickly emerged as one of the most popular frameworks for building React applications. Developed by Vercel, Next.js offers an opinionated and streamlined approach to React development, making it easier to build full-stack web applications with a focus on performance, SEO, and developer experience.&lt;br&gt;
Next.js is a React-based framework that allows developers to build server-side rendering (SSR) and static web applications with ease.&lt;/p&gt;

&lt;p&gt;We will start what our finance dashboard will include&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A public home page.
2.A login page.
3.Dashboard page that are protected by authentication.
4.Ability for user to add edit and delete invoices.
Here is an overview of features that will learn:
styling optimization routing data mutation error handling and authentication etc.
There is a few things one must do before starting , a system requires to install Node.js 18.17 you'll need a Github account and a vercel account.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After running some commands we will explore our project and should have such folders;&lt;br&gt;
/app: Contains all the routes, components, and logic for your application, this is where you'll be mostly working from.&lt;br&gt;
/app/lib: Contains functions used in your application, such as reusable utility functions and data fetching functions.&lt;br&gt;
/app/ui: Contains all the UI components for your application, such as cards, tables, and forms. To save time, we've pre-styled these components for you.&lt;br&gt;
/public: Contains all the static assets for your application, such as images.&lt;br&gt;
will the use this commands to install &lt;code&gt;pnpm i&lt;/code&gt; and to start the development server &lt;code&gt;pnpm dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dashboard page&lt;/strong&gt; includes:&lt;br&gt;
Total Revenue Collected: The total revenue that has been received by the company.&lt;br&gt;
Total Revenue Pending: Revenue that has been invoiced but not yet collected.&lt;br&gt;
Total Invoices: Total number of invoices issued.&lt;br&gt;
Total Customers: The number of customers the company has.&lt;br&gt;
Revenue Chart: A line chart displaying the revenue trends over a period of time.&lt;br&gt;
 &lt;strong&gt;invoice page&lt;/strong&gt;&lt;br&gt;
Customer Information&lt;br&gt;
Invoice Date&lt;br&gt;
Amount Due&lt;br&gt;
Status (e.g., Paid, Unpaid, Pending)&lt;br&gt;
*&lt;em&gt;Authentication *&lt;/em&gt;&lt;br&gt;
on authentication we add a login route were we enable the user to access the web and view customers information, we add passwords for it to be more secured.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>NEXT .JS AND DJANGO OVERVIEW</title>
      <dc:creator>khadyM-hub</dc:creator>
      <pubDate>Mon, 16 Sep 2024 14:13:14 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/next-js-and-django-overview-219c</link>
      <guid>https://dev.to/swahilipotdevs/next-js-and-django-overview-219c</guid>
      <description>&lt;p&gt;Building a dashboard application in Node.js involves creating a real-time, interactive interface to display and manage data. Node.js enables efficient handling of asynchronous operations, making it ideal for fetching data from APIs, integrating databases, and using WebSocket’s for live updates. With frameworks like Express developers can create dynamic charts, tables, and other data visualizations, ensuring the dashboard is both responsive and scalable for various user needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Choose Next.js for a Dashboard&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Server-Side Rendering . Next.js makes server-side rendering easy, which means your app can load faster and perform better.&lt;/li&gt;
&lt;li&gt;Static Site Generation. If you have parts of your dashboard that don’t need frequent updates, you can pre-render those sections for even faster load times.&lt;/li&gt;
&lt;li&gt;Built-in Routing. No need to install additional libraries for routing. Next.js has a simple and intuitive routing system that automatically creates routes based on your file structure.&lt;/li&gt;
&lt;li&gt;API Routes. Next.js allows you to create your own backend APIs within the project, which can be particularly useful when handling data in your dashboard.&lt;/li&gt;
&lt;li&gt;React-Powered. Since Next.js is built on React, you can take advantage of Reacts ecosystem, such as components, hooks, and context, to make your app more modular and interactive.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Planning Your Dashboard&lt;/strong&gt;&lt;br&gt;
**A dashboard typically displays several types of information, such as:&lt;br&gt;
    Metrics and Statistics: Charts, graphs, and key performance indicators (KPIs).&lt;br&gt;
    User Activity: Information about what user is doing, such as recent purchases or logins.&lt;br&gt;
    Notifications Alerts or updates that need attention.&lt;br&gt;
    Data Management: Tools for managing or editing data (e.g., CRUD functionalities).&lt;/p&gt;

&lt;p&gt;With Next.js, you can create a flexible and scalable dashboard, but keep in mind the specific needs of your project as it will guide the type of data and tools you need to include.&lt;/p&gt;

&lt;p&gt;**&lt;br&gt;
Components of a Dashboard**&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigation Bar: This is a menu that helps users move around different sections of the dashboard. It usually contains links to key sections like “Reports,” “Settings,” or “User Management.”&lt;/li&gt;
&lt;li&gt;Sidebar: In more complex dashboards, a sidebar is often used to give users quick access to key features and data without taking up too much screen space.&lt;/li&gt;
&lt;li&gt;Main Content Area: This is the heart of the dashboard. It’s where all your data visualizations, forms, tables, and other components will be displayed. You’ll likely want to structure it in a way that prioritizes important information while still keeping it flexible enough to accommodate different types of content.&lt;/li&gt;
&lt;li&gt;Widgets and Charts: Visual elements like graphs and charts are crucial for representing data in an easily digestible manner. You can use libraries like Chart.js or D3.js in conjunction with Next.js to display data in an attractive and interactive way.&lt;/li&gt;
&lt;li&gt;Search and Filters: For large datasets, you might need to implement search bars or filters so users can easily find the information they’re looking for.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;** Building the Dashboard**&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setting Up the Project&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Start by creating a new Next.js project. Once you have Next.js installed, think about the layout of your dashboard. Next.js makes it easy to create reusable layouts by allowing you to define a global layout file. This is where you’ll define the structure of your navigation bar, sidebar, and main content area.&lt;/p&gt;

&lt;p&gt;Your layout file will act as a template for all the different pages in your dashboard, so you won’t need to repeat yourself for every page.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Creating the Navigation and Sidebar&lt;br&gt;
Your navigation and sidebar are key to making your dashboard user-friendly. Next.js allows you to create separate components for these elements, which makes your code more modular. You can think of the navigation bar as a simple horizontal menu that sits at the top of the page, while the sidebar provides easy access to different sections of the dashboard.&lt;br&gt;
A good practice is to keep the sidebar collapsible. This means users can expand it when needed and hide it when they want to focus on the main content area.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Displaying Data in the Main Content Area&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The main content area is where you will showcase the most important data. Whether you’re displaying user activity, sales data, or performance metrics, the main content area should be clean, organized, and easy to navigate. Next.js, being React-based, allows you to manage data flow seamlessly by using state and props. You’ll likely want to use some kind of data-fetching method, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Static Site Generation: Pre-fetch data during build time if it doesn't change frequently.&lt;/li&gt;
&lt;li&gt;Server-Side Rendering: Fetch data on every request for frequently updated data.&lt;/li&gt;
&lt;li&gt;Client-Side Fetching: Use a hook like &lt;code&gt;use Effect&lt;/code&gt; or libraries like SWR to fetch data from your APIs after the page has loaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Depending on the type of data you're working with, you can choose the most appropriate data-fetching method for your use case.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Integrating Charts and Visualizations&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Charts and visualizations are a big part of what makes a dashboard useful. Whether you're visualizing sales data or tracking performance metrics, integrating a charting library with Next.js is relatively straightforward. &lt;br&gt;
Charts give users a quick snapshot of data trends and insights. Since Next.js handles client-side and server-side rendering efficiently, it ensures that charts load quickly and perform well.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Handling API Requests and Backend Integration&lt;br&gt;
One of the key strengths of Next.js is that it allows you to create API routes within the same project. These API routes can serve as the backend for your dashboard, fetching data from databases, external services, or other APIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search and Filtering Features&lt;br&gt;
If your dashboard manages a large amount of data, you’ll need to give users tools to find the specific information they need. A search bar or filter option is essential in such cases. By integrating client-side search functionalities, users can instantly search through data without needing to reload the page. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;** Best Practices for Dashboard Development**&lt;/p&gt;

&lt;p&gt;Building a dashboard with Next.js is a powerful way to create a high-performance, interactive application. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Optimize for Performance: Dashboards often handle large amounts of data, so it’s crucial to optimize performance by using server-side rendering where needed, lazy loading components, and optimizing API calls.&lt;/li&gt;
&lt;li&gt;Keep It Modular: Next.js’ component-based architecture encourages reusability. Break your dashboard into smaller, reusable components so that you can easily update or scale parts of your application.&lt;/li&gt;
&lt;li&gt;Mobile Responsiveness: Dashboards are often accessed on the go. Ensure that your design is mobile-friendly, providing a smooth user experience across all devices.&lt;/li&gt;
&lt;li&gt;Security and Authentication: Dashboards often handle sensitive data, so consider implementing authentication using tools like NextAuth.js. Secure your API routes to protect sensitive data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;DJANGO&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;*&lt;em&gt;Introduction&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Django 5.1 is a significant release of the popular Python web framework known for its simplicity and&lt;br&gt;
robustness. This article provides a thorough overview of its features, improvements, and architectural&lt;br&gt;
changes, offering insights into how Django 5.1 enhances web development processes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features and Improvements&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enhanced ORM Capabilities&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Django 5.1 introduces several enhancements to its Object-Relational Mapping (ORM) system. These&lt;br&gt;
include improvements in query optimization and additional features for complex queries. The ORM&lt;br&gt;
remains a core strength of Django, providing an efficient way to interact with the database without&lt;br&gt;
writing raw SQL.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Updated Middleware Framework&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The middleware framework has been updated to improve performance and flexibility. Middleware&lt;br&gt;
components can now be configured more easily, and new hooks are available for custom processing of&lt;br&gt;
requests and responses. This change aims to streamline the development of custom middleware.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improved Form Handling&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Form handling in Django 5.1 has been refined to offer better validation and customization options.&lt;br&gt;
Developers can now leverage enhanced form processing features to create more robust and user-&lt;br&gt;
friendly forms.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enhanced Security Features&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Security continues to be a top priority in Django 5.1. This release includes updates to protect against&lt;br&gt;
common web vulnerabilities. Improvements in authentication and authorization mechanisms ensure&lt;br&gt;
that applications built with Django are secure by default.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Updated Template System&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The template system in Django 5.1 has been updated to provide better performance and new features.&lt;br&gt;
These updates include enhancements to template rendering and new options for template&lt;br&gt;
customization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Architecture and Design&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Modular Design&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Django 5.1 emphasizes a modular design, allowing developers to work on different components of their&lt;br&gt;
application independently. This modularity supports better maintainability and scalability of web&lt;br&gt;
applications.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Asynchronous Support&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Asynchronous support has been enhanced in Django 5.1, making it easier to build asynchronous views&lt;br&gt;
and handle asynchronous tasks. This improvement aligns with modern web development practices and&lt;br&gt;
enhances the performance of Django applications.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improved Admin Interface&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The admin interface, a hallmark of Django, has been improved in this release. The enhancements&lt;br&gt;
include better usability and additional customization options, allowing developers to tailor the admin&lt;br&gt;
interface to their needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Development and Deployment&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Development Tools&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Django 5.1 introduces new development tools and improvements to existing ones. These tools aim to&lt;br&gt;
enhance the development experience by providing better debugging, testing, and profiling capabilities.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deployment Considerations&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With the new release, deployment practices are also addressed. Django 5.1 includes updates that&lt;br&gt;
simplify deployment and integration with various deployment environments. These updates ensure that&lt;br&gt;
applications can be deployed smoothly and efficiently.&lt;/p&gt;

&lt;p&gt;Community and Ecosystem&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Community Contributions&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Django community continues to play a vital role in the framework’s development. Django 5.1&lt;br&gt;
includes contributions from various community members, reflecting the collaborative nature of the&lt;br&gt;
project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ecosystem Integration&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Django 5.1 maintains compatibility with various third-party packages and tools, ensuring that developers&lt;br&gt;
can continue to leverage a wide range of extensions and integrations. This compatibility supports a rich ecosystem around django&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Step by step guide to build an app using :1.next.js 2.django.</title>
      <dc:creator>liz nzisa</dc:creator>
      <pubDate>Mon, 16 Sep 2024 14:10:16 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/project-documentation-finance-app-and-polling-appnextjs-finance-app-5fk8</link>
      <guid>https://dev.to/swahilipotdevs/project-documentation-finance-app-and-polling-appnextjs-finance-app-5fk8</guid>
      <description>&lt;p&gt;project Documentation: Next.js Finance App &amp;amp; Django Polling App&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Next.js Finance App
&lt;/h2&gt;

&lt;p&gt;Project Overview&lt;/p&gt;

&lt;p&gt;This project is a finance application built using Next.js. It allows users to log in, view invoices, collected amounts, add or edit customers, and view customer and invoice pages. It also provides a recent revenue summary for financial tracking.&lt;/p&gt;

&lt;p&gt;The app uses PostgreSQL as the primary database, enhanced with MySQL logic for optimized queries. The app is successfully deployed on Vercel.&lt;br&gt;
**&lt;br&gt;
 &lt;strong&gt;Features&lt;/strong&gt;&lt;br&gt;
    Authentication: Secure login system to access personal accounts.&lt;br&gt;
    Invoice Management: View, edit, and manage invoices and track the total amount collected.&lt;br&gt;
    Customer Management: Add, view, and edit customer information.&lt;br&gt;
    Revenue Summary: View the most recent revenue generated from customer invoices.&lt;br&gt;
    Database: PostgreSQL integrated with MySQL logic.&lt;br&gt;
    Deployment: Deployed on Vercel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;br&gt;
Step 1: Install Node.js and Next.js&lt;/p&gt;

&lt;p&gt;Install Node.js&lt;br&gt;
&lt;code&gt;sudo apt update&lt;br&gt;
sudo apt install nodejs&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Install Next.js and create a new project&lt;br&gt;
&lt;code&gt;npx create-next-app@latest finance-app&lt;br&gt;
cd finance-app&lt;br&gt;
npm install&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;Step 2: Install PostgreSQL&lt;/p&gt;

&lt;p&gt;Install PostgreSQL&lt;br&gt;
&lt;code&gt;sudo apt update&lt;br&gt;
sudo apt install postgresql postgresql-contrib&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Start PostgreSQL&lt;br&gt;
&lt;code&gt;sudo service postgresql start&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 3: Setup MySQL (Optional for Logic)&lt;/p&gt;

&lt;p&gt;Install MySQL&lt;br&gt;
&lt;code&gt;sudo apt install mysql-server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Start MySQL&lt;br&gt;
&lt;code&gt;sudo service mysql start&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 4: Run Development Server&lt;/p&gt;

&lt;p&gt;Start the Next.js development server&lt;br&gt;
&lt;code&gt;npm run dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Key Concepts&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Routing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Next.js provides a file-based routing system. The app has routes for invoices, customers, and revenue pages:&lt;/p&gt;

&lt;p&gt;js&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;// Example: Invoice route in pages/invoices/[id].js&lt;br&gt;
import { useRouter } from 'next/router';&lt;/p&gt;

&lt;p&gt;export default function InvoicePage() {&lt;br&gt;
    const router = useRouter();&lt;br&gt;
    const { id } = router.query;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return &amp;lt;div&amp;gt;Invoice ID: {id}&amp;lt;/div&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Data Fetching&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Server-side rendering (SSR) with getServerSideProps ensures real-time data updates for viewing recent revenue and invoice details:&lt;/p&gt;

&lt;p&gt;js&lt;br&gt;
&lt;code&gt;&lt;/code&gt;&lt;br&gt;
export async function getServerSideProps() {&lt;br&gt;
    const invoices = await fetchInvoicesFromDB();&lt;br&gt;
    return { props: { invoices } };&lt;br&gt;
}&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Form Validation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using react-hook-form and yup for form validation when adding/editing customer information:&lt;/p&gt;

&lt;p&gt;js&lt;/p&gt;

&lt;p&gt;`import { useForm } from 'react-hook-form';&lt;br&gt;
import * as yup from 'yup';&lt;/p&gt;

&lt;p&gt;const schema = yup.object().shape({&lt;br&gt;
  customerName: yup.string().required(),&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;export default function AddCustomer() {&lt;br&gt;
  const { register, handleSubmit } = useForm({&lt;br&gt;
    validationSchema: schema,&lt;br&gt;
  });&lt;/p&gt;

&lt;p&gt;const onSubmit = data =&amp;gt; console.log(data);&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
      &lt;br&gt;
      Submit&lt;br&gt;
    &lt;br&gt;
  );&lt;br&gt;
}`

&lt;ol&gt;
&lt;li&gt;Error Handling&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Handled via custom error pages (404.js, 500.js) to enhance the user experience:&lt;/p&gt;

&lt;p&gt;js&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export default function Custom404() {&lt;br&gt;
  return &amp;lt;h1&amp;gt;404 - Page Not Found&amp;lt;/h1&amp;gt;;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Authentication&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implemented using NextAuth.js to secure login functionality:&lt;/p&gt;

&lt;p&gt;js&lt;br&gt;
&lt;code&gt;&lt;/code&gt;&lt;br&gt;
`import { signIn, useSession } from 'next-auth/react';&lt;/p&gt;

&lt;p&gt;export default function Login() {&lt;br&gt;
  const { data: session } = useSession();&lt;/p&gt;

&lt;p&gt;if (session) {&lt;br&gt;
    return &lt;/p&gt;
&lt;p&gt;Welcome {session.user.email}&lt;/p&gt;;&lt;br&gt;
  }

&lt;p&gt;return  signIn()}&amp;gt;Sign In;&lt;br&gt;
}&lt;br&gt;
``&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Styling&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Styled using Tailwind CSS for responsive and modern UI design:&lt;/p&gt;

&lt;p&gt;html&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div className="bg-gray-200 p-4"&amp;gt;&lt;br&gt;
    &amp;lt;h1 className="text-2xl font-bold"&amp;gt;Recent Revenue&amp;lt;/h1&amp;gt;&lt;br&gt;
    &amp;lt;p&amp;gt;Total Revenue: $5000&amp;lt;/p&amp;gt;&lt;br&gt;
&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Meta Data &amp;amp; SEO&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Handled through the Next.js &lt;/p&gt; component for SEO:

&lt;p&gt;js&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Head&amp;gt;&lt;br&gt;
  &amp;lt;title&amp;gt;Finance App - Recent Revenue&amp;lt;/title&amp;gt;&lt;br&gt;
  &amp;lt;meta name="description" content="View your recent revenue and manage invoices" /&amp;gt;&lt;br&gt;
&amp;lt;/Head&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Django Polling App
Project Overview&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This project is a polling application created using Django. It allows users to vote on polls and view poll results. The admin interface enables the creation, modification, and deletion of polls.&lt;/p&gt;

&lt;p&gt;The project features two models: Question and Choice. Each Question has associated Choices for users to vote on, and each Choice tracks the number of votes.&lt;br&gt;
Features&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Public Polling: Allows users to view and vote on polls.
Admin Interface: Manage polls, add questions, and track votes.
Models:
    Question model with the question text and publication date.
    Choice model with the choice text and vote count, linked to Question.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Installation&lt;br&gt;
Step 1: Install Python and Django&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;

&lt;p&gt;Install Python&lt;br&gt;
&lt;code&gt;sudo apt update&lt;br&gt;
sudo apt install python3&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Install Django&lt;br&gt;
&lt;code&gt;pip install django&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 2: Create a Django Project&lt;/p&gt;

&lt;p&gt;&lt;code&gt;django-admin startproject polls_project&lt;br&gt;
cd polls_project&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Start Django development server
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;python manage.py runserver&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 3: Setup Database (SQLite by default)&lt;/p&gt;

&lt;p&gt;Migrate to initialize database&lt;br&gt;
&lt;code&gt;python manage.py migrate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 4: Create Polling Models&lt;/p&gt;

&lt;p&gt;python&lt;/p&gt;

&lt;p&gt;models.py&lt;br&gt;
from django.db import models&lt;/p&gt;

&lt;p&gt;class Question(models.Model):&lt;br&gt;
    question_text = models.CharField(max_length=200)&lt;br&gt;
    pub_date = models.DateTimeField('date published')&lt;/p&gt;

&lt;p&gt;class Choice(models.Model):&lt;br&gt;
    question = models.ForeignKey(Question, on_delete=models.CASCADE)&lt;br&gt;
    choice_text = models.CharField(max_length=200)&lt;br&gt;
    votes = models.IntegerField(default=0)`&lt;/p&gt;

&lt;p&gt;Key Concepts&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Routing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Django's URL routing mechanism is used for linking views with URLs:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
` urls.py&lt;br&gt;
from django.urls import path&lt;br&gt;
from . import views&lt;/p&gt;

&lt;p&gt;urlpatterns = [&lt;br&gt;
    path('', views.index, name='index'),&lt;br&gt;
    path('&lt;a&gt;int:question_id&lt;/a&gt;/', views.detail, name='detail'),&lt;br&gt;
    path('&lt;a&gt;int:question_id&lt;/a&gt;/vote/', views.vote, name='vote'),&lt;br&gt;
]&lt;br&gt;
`&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Form Validation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Form validation is used when submitting votes, ensuring that valid data is submitted:&lt;/p&gt;

&lt;p&gt;python&lt;/p&gt;

&lt;p&gt;`forms.py&lt;br&gt;
from django import forms&lt;/p&gt;

&lt;p&gt;class VoteForm(forms.Form):&lt;br&gt;
    choice = forms.ChoiceField(choices=[(choice.id, choice.choice_text) for choice in choices])`&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Admin Interface&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Django admin panel is used to manage questions and choices:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
`&lt;br&gt;
from django.contrib import admin&lt;br&gt;
from .models import Question, Choice&lt;/p&gt;

&lt;p&gt;admin.site.register(Question)&lt;br&gt;
admin.site.register(Choice)`&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Error Handling&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Custom error messages are displayed if an invalid poll or vote is submitted:&lt;/p&gt;

&lt;p&gt;python&lt;/p&gt;

&lt;p&gt;&lt;code&gt;def vote(request, question_id):&lt;br&gt;
    try:&lt;br&gt;
        question = get_object_or_404(Question, pk=question_id)&lt;br&gt;
    except KeyError:&lt;br&gt;
        return render(request, 'polls/detail.html', {'error_message': "You didn't select a choice."})&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Styling&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The app uses Bootstrap for a clean, responsive interface:&lt;/p&gt;

&lt;p&gt;html&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;&lt;br&gt;
    &amp;lt;h1&amp;gt;Poll Results&amp;lt;/h1&amp;gt;&lt;br&gt;
    &amp;lt;p&amp;gt;{{ question.question_text }}&amp;lt;/p&amp;gt;&lt;br&gt;
&amp;lt;/div&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Meta Data&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Meta tags are used to improve SEO:&lt;/p&gt;

&lt;p&gt;html&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;meta name="description" content="Vote on the latest polls and view poll results."&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DEVELOPING A FINANCIAL DASHBOARD APPLICATION USING NEXT.JS</title>
      <dc:creator>Abubakar Hassan</dc:creator>
      <pubDate>Mon, 16 Sep 2024 14:08:34 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/learning-the-nextjs-4pob</link>
      <guid>https://dev.to/swahilipotdevs/learning-the-nextjs-4pob</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;INTRODUCTION&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Over the past two weeks, I worked on developing a financial dashboard application using Next.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;TABLE OF CONTENTS&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What to be Developed &lt;/li&gt;
&lt;li&gt;Overview of Application &lt;/li&gt;
&lt;li&gt;System Requirements&lt;/li&gt;
&lt;li&gt;Getting Started &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;WHAT TO BE DEVELOPED&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A financial dashboard home page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A login page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Financial dashboard layout.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;OVERVIEW OF APPLICATION&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the development of the financial dashboard application, there are some features that are going to be implemented like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Styling: The different ways to style your application in Next.js.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optimizations: How to optimize images, links, and fonts.&lt;br&gt;
Routing: How to create nested layouts and pages using file-system routing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data Fetching: How to set up a database on Vercel, and best practices for fetching and streaming.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;SYSTEM REQUIREMENTS&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This involves the system requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Node.js 18.17.0 or later &lt;a href="https://nodejs.org/en/download/prebuilt-installer/current" rel="noopener noreferrer"&gt;Download Node.js&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Operating systems: macOS, Windows (including WSL), or Linux.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visual Code editor.&lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;Download VisualStudio Code&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;GETTING STARTED&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Creating The Financial Dashboard Application:&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You need to install the &lt;a href="https://pnpm.io/" rel="noopener noreferrer"&gt;pnpm&lt;/a&gt; as your package manager, and if you don't have pnpm install in your operating system, install by running this command on terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then to create a Next.js financial dashboard app, open your terminal, navigate to directory you want your app folder to be and then run the following command in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example" --use-pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Folder Structure:&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;You'll notice that the project has the following folder structure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;/app: Contains all the routes, components, and logic for your application, this is where you'll be mostly working from.&lt;/li&gt;
&lt;li&gt;/app/lib: Contains functions used in your application, such as reusable utility functions and data fetching functions.&lt;/li&gt;
&lt;li&gt;/app/ui: Contains all the UI components for your application, such as cards, tables, and forms. &lt;/li&gt;
&lt;li&gt;/public: Contains all the static assets for your application, such as images.&lt;/li&gt;
&lt;li&gt;Config Files: You'll also notice config files such as next.config.js at the root of your application. Most of these files are created and pre-configured when you start a new project using create-next-app.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Running The Development Server:&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run pnpm i on your terminal to install the project's packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Followed by pnpm dev to start the development server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;pnpm dev starts your Next.js development server. Check to see if it's working.&lt;br&gt;
Open &lt;a href="http://localhost:3000/" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; on your browser. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;CREATING A FINANCIAL DASHBOARD HOME PAGE&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The home page will created by adding the images and fonts. To add the images, use the &lt;strong&gt;next/image&lt;/strong&gt; component to automatically optimize your images.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Adding The Desktop Hero Image;&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In your &lt;strong&gt;/app/page.tsx&lt;/strong&gt; file, import the component from next/image. Then, add the image by using the following statements below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import AcmeLogo from '@/app/ui/acme-logo';
import { ArrowRightIcon } from '@heroicons/react/24/outline';
import Link from 'next/link';
import { lusitana } from '@/app/ui/fonts';
import Image from 'next/image';

export default function Page() {
  return (
    // ...
    &amp;lt;div className="flex items-center justify-center p-6 md:w-3/5 md:px-28 md:py-12"&amp;gt;
      {/* Add Hero Images Here */}
      &amp;lt;Image
        src="/hero-desktop.png"
        width={1000}
        height={760}
        className="hidden md:block"
        alt="Screenshots of the dashboard project showing desktop version"
      /&amp;gt;
    &amp;lt;/div&amp;gt;
    //...
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Adding The Mobile Hero Image;&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To add the Mobile Hero Image, in the same &lt;strong&gt;/app/page.tsx&lt;/strong&gt; add the following statements below the Desktop Hero Image statements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{/* Add Hero Images Here */}
      &amp;lt;Image
        src="/hero-desktop.png"
        width={1000}
        height={760}
        className="hidden md:block"
        alt="Screenshots of the dashboard project showing desktop version"
      /&amp;gt;
      &amp;lt;Image
        src="/hero-mobile.png"
        width={560}
        height={620}
        className="block md:hidden"
        alt="Screenshot of the dashboard project showing mobile version"
      /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's add some fonts to that home page. In your &lt;strong&gt;/app/ui&lt;/strong&gt; folder, create a new file called fonts.ts. You'll use this file to keep the fonts that will be used throughout your application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Inter } from 'next/font/google';

export const inter = Inter({ subsets: ['latin'] });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, add the font to the &lt;/p&gt; element in &lt;strong&gt;/app/layout.tsx&lt;/strong&gt;:&lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import '@/app/ui/global.css';
import { inter } from '@/app/ui/fonts';

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    &amp;lt;html lang="en"&amp;gt;
      &amp;lt;body className={`${inter.className} antialiased`}&amp;gt;{children}&amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;So now the financial dashboard application home page will look like this below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzx08r8se2usvht33fiw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzx08r8se2usvht33fiw.png" alt="Home page" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;CREATING A LOGIN PAGE&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start by creating a new route called /login and paste the following code in your &lt;strong&gt;/app/login/page.tsx&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;import AcmeLogo from '@/app/ui/acme-logo';
import LoginForm from '@/app/ui/login-form';

export default function LoginPage() {
  return (
    &amp;lt;main className="flex items-center justify-center md:h-screen"&amp;gt;
      &amp;lt;div className="relative mx-auto flex w-full max-w-[400px] flex-col space-y-2.5 p-4 md:-mt-32"&amp;gt;
        &amp;lt;div className="flex h-20 w-full items-end rounded-lg bg-blue-500 p-3 md:h-36"&amp;gt;
          &amp;lt;div className="w-32 text-white md:w-36"&amp;gt;
            &amp;lt;AcmeLogo /&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;LoginForm /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll notice the page imports &lt;strong&gt;&lt;/strong&gt;. We will be using the NextAuth.js to add authentication to our application. &lt;strong&gt;NextAuth.js&lt;/strong&gt; abstracts away much of the complexity involved in managing sessions, &lt;strong&gt;sign-in&lt;/strong&gt; and &lt;strong&gt;sign-out&lt;/strong&gt;, and other aspects of authentication.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Setting Up NextAuth.js;&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Install NextAuth.js by running the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm i next-auth@beta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you're installing the beta version of NextAuth.js, which is compatible with Next.js 14.&lt;br&gt;
Next, generate a secret key for your application. This key is used to encrypt cookies, ensuring the security of user sessions. You can do this by running the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl rand -base64 32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, in your .env file, add your generated key to the AUTH_SECRET variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AUTH_SECRET=your-secret-key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Adding The Page Options;&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Create an auth.config.ts file at the root of our project that exports an authConfig object. This object will contain the configuration options for NextAuth.js. For now, it will only contain the pages option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import type { NextAuthConfig } from 'next-auth';

export const authConfig = {
  pages: {
    signIn: '/login',
  },
} satisfies NextAuthConfig;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use the pages option to specify the route for custom &lt;strong&gt;sign-in&lt;/strong&gt;, &lt;strong&gt;sign-out&lt;/strong&gt;, and error pages. This is not required, but by adding signIn: '&lt;strong&gt;/login&lt;/strong&gt;' into our pages option, the user will be redirected to our custom login page, rather than the NextAuth.js default page.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Protecting Your Routes With Next.js Middleware;&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next, add the logic to protect your routes. This will prevent users from accessing the dashboard pages unless they are logged in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import type { NextAuthConfig } from 'next-auth';

export const authConfig = {
  pages: {
    signIn: '/login',
  },
  callbacks: {
    authorized({ auth, request: { nextUrl } }) {
      const isLoggedIn = !!auth?.user;
      const isOnDashboard = nextUrl.pathname.startsWith('/dashboard');
      if (isOnDashboard) {
        if (isLoggedIn) return true;
        return false; // Redirect unauthenticated users to login page
      } else if (isLoggedIn) {
        return Response.redirect(new URL('/dashboard', nextUrl));
      }
      return true;
    },
  },
  providers: [], // Add providers with an empty array for now
} satisfies NextAuthConfig;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The authorized callback is used to verify if the request is authorized to access a page via Next.js Middleware. It is called before a request is completed, and it receives an object with the auth and request properties. The auth property contains the user's session, and the request property contains the incoming request.&lt;br&gt;
Next, you will need to import the authConfig object into a Middleware file. In the root of your project, create a file called middleware.ts and paste the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import NextAuth from 'next-auth';
import { authConfig } from './auth.config';

export default NextAuth(authConfig).auth;

export const config = {
  // https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
  matcher: ['/((?!api|_next/static|_next/image|.*\\.png$).*)'],
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you're initializing NextAuth.js with the authConfig object and exporting the auth property. You're also using the matcher option from Middleware to specify that it should run on specific paths. Then create a new file called &lt;strong&gt;auth.ts&lt;/strong&gt; that spreads your authConfig object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import NextAuth from 'next-auth';
import { authConfig } from './auth.config';

export const { auth, signIn, signOut } = NextAuth({
  ...authConfig,
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Adding The Credentials Providers;&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next, you will need to add the providers option for NextAuth.js. providers is an array where you list different login options such as Google or GitHub. The Credentials provider allows users to log in with a username and a password. In your &lt;strong&gt;/auth.ts&lt;/strong&gt; add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import NextAuth from 'next-auth';
import { authConfig } from './auth.config';
import Credentials from 'next-auth/providers/credentials';

export const { auth, signIn, signOut } = NextAuth({
  ...authConfig,
  providers: [Credentials({})],
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Adding The Sign In Functionality;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can use the authorize function to handle the authentication logic. Similarly to Server Actions, you can use zod to validate the email and password before checking if the user exists in the database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import NextAuth from 'next-auth';
import { authConfig } from './auth.config';
import Credentials from 'next-auth/providers/credentials';
import { z } from 'zod';

export const { auth, signIn, signOut } = NextAuth({
  ...authConfig,
  providers: [
    Credentials({
      async authorize(credentials) {
        const parsedCredentials = z
          .object({ email: z.string().email(), password: z.string().min(6) })
          .safeParse(credentials);
      },
    }),
  ],
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After validating the credentials, create a new getUser function that queries the user from the database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { sql } from '@vercel/postgres';
import type { User } from '@/app/lib/definitions';
import bcrypt from 'bcrypt';

async function getUser(email: string): Promise&amp;lt;User | undefined&amp;gt; {
  try {
    const user = await sql&amp;lt;User&amp;gt;`SELECT * FROM users WHERE email=${email}`;
    return user.rows[0];
  } catch (error) {
    console.error('Failed to fetch user:', error);
    throw new Error('Failed to fetch user.');
  }
}

if (parsedCredentials.success) {
          const { email, password } = parsedCredentials.data;
          const user = await getUser(email);
          if (!user) return null;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Updating The Login Form;&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now you need to connect the auth logic with your login form. In your &lt;strong&gt;/actions.ts&lt;/strong&gt; file, create a new action called authenticate. This action should import the signIn function from &lt;strong&gt;/auth.ts&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;'use server';

import { signIn } from '@/auth';
import { AuthError } from 'next-auth';

// ...

export async function authenticate(
  prevState: string | undefined,
  formData: FormData,
) {
  try {
    await signIn('credentials', formData);
  } catch (error) {
    if (error instanceof AuthError) {
      switch (error.type) {
        case 'CredentialsSignin':
          return 'Invalid credentials.';
        default:
          return 'Something went wrong.';
      }
    }
    throw error;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, in your login-form.tsx component, you can use React's useActionState to call the server action, handle form errors, and display the form's pending state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useActionState } from 'react';
import { authenticate } from '@/app/lib/actions';

const [errorMessage, formAction, isPending] = useActionState(
    authenticate,
    undefined,
  );

&amp;lt;form action={formAction} className="space-y-3"&amp;gt;

&amp;lt;Button className="mt-4 w-full" aria-disabled={isPending}&amp;gt;
          Log in &amp;lt;ArrowRightIcon className="ml-auto h-5 w-5 text-gray-50" /&amp;gt;
        &amp;lt;/Button&amp;gt;

{errorMessage &amp;amp;&amp;amp; (
            &amp;lt;&amp;gt;
              &amp;lt;ExclamationCircleIcon className="h-5 w-5 text-red-500" /&amp;gt;
              &amp;lt;p className="text-sm text-red-500"&amp;gt;{errorMessage}&amp;lt;/p&amp;gt;
            &amp;lt;/&amp;gt;
          )}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Adding Logout Functionality;&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To add the logout functionality to , call the signOut function from auth.ts in your &lt;/p&gt; element:&lt;br&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { signOut } from '@/auth';

action={async () =&amp;gt; {
            'use server';
            await signOut();
          }}
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Now, try it out. You should be able to log in and out of your application. The login page should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi1ps90fabgicxqsqze6m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi1ps90fabgicxqsqze6m.png" alt="Login Page" width="573" height="669"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;CREATING DASHBOARD LAYOUT&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dashboards have some sort of navigation that is shared across multiple pages. In Next.js, you can use a special &lt;strong&gt;/layout.tsx&lt;/strong&gt; file to create UI that is shared between multiple pages. inside the &lt;strong&gt;/dashboard&lt;/strong&gt; folder, add a new file called &lt;strong&gt;/layout.tsx&lt;/strong&gt; and paste the following code:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import SideNav from '@/app/ui/dashboard/sidenav';

export default function Layout({ children }: { children: React.ReactNode }) {
  return (
    &amp;lt;div className="flex h-screen flex-col md:flex-row md:overflow-hidden"&amp;gt;
      &amp;lt;div className="w-full flex-none md:w-64"&amp;gt;
        &amp;lt;SideNav /&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className="flex-grow p-6 md:overflow-y-auto md:p-12"&amp;gt;{children}&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;You'll see the dashboard layout like this below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs2i3tjki4wys9eefpt8x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs2i3tjki4wys9eefpt8x.png" alt="Dashboard Layout" width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also set up pages for the /customers and /invoices.&lt;br&gt;
&lt;em&gt;Customers Page&lt;/em&gt;: /app/dashboard/customers/page.tsx&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Page() {
  return &amp;lt;p&amp;gt;Customers Page&amp;lt;/p&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Invoices Page&lt;/em&gt;: /app/dashboard/invoices/page.tsx&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Page() {
  return &amp;lt;p&amp;gt;Invoices Page&amp;lt;/p&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Navigation Between Pages:&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In Next.js, you can use the &lt;strong&gt;&lt;/strong&gt; Component to link between pages in your application. &lt;strong&gt;&lt;/strong&gt; allows you to do client-side navigation with JavaScript. To use the  component, open &lt;strong&gt;/app/ui/dashboard/nav-links.tsx&lt;/strong&gt;, and import the Link component from next/link. Then, replace the &lt;strong&gt;&lt;a&gt;&lt;/a&gt;&lt;/strong&gt; tag with &lt;strong&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {
  UserGroupIcon,
  HomeIcon,
  DocumentDuplicateIcon,
} from '@heroicons/react/24/outline';
**import Link from 'next/link';**

// ...

export default function NavLinks() {
  return (
    &amp;lt;&amp;gt;
      {links.map((link) =&amp;gt; {
        const LinkIcon = link.icon;
        return (
          &amp;lt;Link
            key={link.name}
            href={link.href}
            className="flex h-[48px] grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 text-sm font-medium hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3"
          &amp;gt;
            &amp;lt;LinkIcon className="w-6" /&amp;gt;
            &amp;lt;p className="hidden md:block"&amp;gt;{link.name}&amp;lt;/p&amp;gt;
          &amp;lt;/Link&amp;gt;
        );
      })}
    &amp;lt;/&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;CREATING THE DATABASE&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Create A Github Repository;&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To start, let's push your repository to Github if you haven't done so already. This will make it easier to set up your database and deploy. If you need help setting up your repository, take a look at this &lt;a href="https://help.github.com/en/github/getting-started-with-github/create-a-repo" rel="noopener noreferrer"&gt;guide on Github&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;&lt;u&gt;Create A Vercel Account;&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Visit &lt;a href="https://vercel.com/signup" rel="noopener noreferrer"&gt;Vercel.com&lt;/a&gt; to create an account. Choose the free "hobby" plan. Select Continue with GitHub to connect your GitHub and Vercel accounts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Connect And Deploy Your Project;&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You'll be taken to this screen where you can select and import the GitHub repository you've just created:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbsi1ogdhflgd2iod58ni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbsi1ogdhflgd2iod58ni.png" alt="Vercel Dashboard" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Name your project and click &lt;strong&gt;Deploy&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;&lt;u&gt;Create A Postgres Database;&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To set up a database, click Continue to Dashboard and select the Storage tab from your project dashboard. Select Connect Store → Create New → Postgres → Continue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvub6t1b0wyqrg5mg1m0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvub6t1b0wyqrg5mg1m0g.png" alt="Postgress Database" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>typescript</category>
      <category>nextjs</category>
      <category>webdev</category>
    </item>
    <item>
      <title>NEXT JS</title>
      <dc:creator>jieva163</dc:creator>
      <pubDate>Mon, 16 Sep 2024 13:53:15 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/technical-symbols-for-next-js-for-the-last-two-weeks-1f85</link>
      <guid>https://dev.to/swahilipotdevs/technical-symbols-for-next-js-for-the-last-two-weeks-1f85</guid>
      <description>&lt;p&gt;The following are some of the charpters i learned,and did;&lt;br&gt;
optimizing Fonts and Images;&lt;br&gt;
&lt;strong&gt;Creating Layouts and Pages;&lt;/strong&gt;&lt;br&gt;
. Set Up Node.js&lt;br&gt;
install node.js in your computer,next js requirs node.js version.&lt;br&gt;
&lt;strong&gt;b. Create a New Next.js&lt;/strong&gt;&lt;br&gt;
create a new Next.js project quickly. Open your terminal or command prompt and run the following command&lt;br&gt;
Navigating Between Pages;&lt;br&gt;
Setting Up Your Database in vercel;&lt;br&gt;
Executing queries;;&lt;br&gt;
npx is a package runner tool that comes with Node.js.&lt;br&gt;
create-next-app is a tool that sets up a new Next.js project with a default configuration.&lt;br&gt;
my-nextjs-project is the name of the folder where your project will be created. &lt;br&gt;
&lt;strong&gt;.API lAYER&lt;/strong&gt;&lt;br&gt;
APIs are an intermediary layer between your application code and database. There are a few cases where you might use an API:&lt;br&gt;
    • If you're using 3rd party services that provide an API. &lt;br&gt;
    • If you're fetching data from the client, you want to have an API layer that runs on the server to avoid exposing your database secrets to the client. &lt;br&gt;
In Next.js, you can create API endpoints using Route Handlers.&lt;br&gt;
Database queries&lt;br&gt;
When you're creating a full-stack application, you'll also need to write logic to interact with your database. For relational databases&lt;br&gt;
like Postgres, you can do this with SQL or with an ORM&lt;br&gt;
.&lt;strong&gt;SETTING UP DATABASE IN VERCEL&lt;/strong&gt;.&lt;br&gt;
There are a few cases where you have to write database queries:&lt;br&gt;
    •&lt;br&gt;
 When creating your API endpoints, you need to write logic to interact with your database. &lt;/p&gt;

&lt;p&gt;If you are using React Server Components (fetching data on the server), you can skip the API layer, and query your database directly without risking exposing your database secrets to the client.&lt;br&gt;
when creating a postgres data base u should first create new postgres, Once connected, navigate to the .env.local tab, click Show secret and Copy Snippet. Make sure you reveal the secrets before copying them.the following is the secret after coppying the snippet;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`POSTGRES_URL="postgres://default:FWuODZz9B5Td@ep-withered-recipe-a48czbnm-pooler.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require"
POSTGRES_PRISMA_URL="postgres://default:FWuODZz9B5Td@ep-withered-recipe-a48czbnm-pooler.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require&amp;amp;pgbouncer=true&amp;amp;connect_timeout=15"
POSTGRES_URL_NO_SSL="postgres://default:FWuODZz9B5Td@ep-withered-recipe-a48czbnm-pooler.us-east-1.aws.neon.tech:5432/verceldb"
POSTGRES_URL_NON_POOLING="postgres://default:FWuODZz9B5Td@ep-withered-recipe-a48czbnm.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require"
POSTGRES_USER="default"
POSTGRES_HOST="ep-withered-recipe-a48czbnm-pooler.us-east-1.aws.neon.tech"
POSTGRES_PASSWORD="FWuODZz9B5Td"
POSTGRES_DATABASE="verceldb"`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;HOW TO FETCH DATA&lt;/strong&gt;&lt;br&gt;
Using Server Components to fetch data&lt;br&gt;
By default, Next.js applications use React Server Components. Fetching data with Server Components is a relatively new approach and there are a few benefits of using them:&lt;/p&gt;

&lt;p&gt;Server Components support promises, providing a simpler solution for asynchronous tasks like data fetching. You can use async/await syntax without reaching out for useEffect, useState or data fetching libraries. &lt;br&gt;
 Server Components execute on the server, so you can keep expensive data fetches and logic on the server and only send the result to the client. &lt;/p&gt;

&lt;p&gt;Server Components execute on the server, you can query the database directly without an additional API layer.  In the case of data fetching, each request can only begin once the previous request has returned data.&lt;br&gt;
Static and Dynamic Rendering&lt;/p&gt;

&lt;p&gt;Streaming is a data transfer technique that allows you to break down a route into smaller "chunks" and progressively stream them from the server to the client as they become ready.&lt;/p&gt;

&lt;p&gt;By streaming, you can prevent slow data requests from blocking your whole page. This allows the user to see and interact with parts of the page without waiting for all the data to load before any UI can be shown to the user&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A COMPREHENSIVE GUIDE OF NEXTJS</title>
      <dc:creator>aheed192</dc:creator>
      <pubDate>Mon, 16 Sep 2024 13:52:19 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/a-comprehensive-guide-of-nextjs-arcticle-4blb</link>
      <guid>https://dev.to/swahilipotdevs/a-comprehensive-guide-of-nextjs-arcticle-4blb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next.js is a React framework that offers an optimized development experience for building modern web applications. It provides features like server-side rendering (SSR), static site generation (SSG), API routes, and more, allowing developers to build performant and scalable application.&lt;/p&gt;

&lt;p&gt;TECH STACK USED WHEN DOING IT&lt;br&gt;
Fronted: next&lt;br&gt;
Backend: NodeJS&lt;br&gt;
Database: Postgres&lt;br&gt;
Deployment: Vercel (Vercel linked with GitHub)&lt;/p&gt;

&lt;p&gt;CREATING A NEW PROJECT&lt;br&gt;
i recommend using pnpm as your package manager, as it's faster and more efficient than npm or yarn. If you don't have pnpm installed, you can install it globally by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`npm install -g pnpm`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a Next.js app, open your terminal, cd into the folder you'd like to keep your project, and run the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`npx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example" --use-pnpm`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, open the project in your code editor and navigate to nextjs-dashboard.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`cd nextjs-dashboard`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;KEY FEATURES OF NEXTJS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;THE LOGIN PAGE &lt;br&gt;
This section will guide you through building a login page in Next.js with a basic form for user input and client-side state management. This example assumes you are handling authentication via API routes and a backend service.to add authenticate to access the next page we use NextAuth. We install the NextAuth.js by running the following commands in your terminal;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`pnpm i next-auth@beta`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, generate a secret code for your application, you can do this by running the following commands in your terminal;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`openssl rand -base64 32`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in your .env file, add your generated key to the AUTH_SECRET VARIABLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`AUTH_SECRET=your-secret-key`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;THE DASHBOARD&lt;br&gt;
In this section, we'll build a basic dashboard in Next.js. This dashboard will include a protected route that ensures only authenticated users can access it. For simplicity, this example assumes that user authentication is handled with session-based authentication using API routes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PAGES FOUND IN THE DASHBOARD&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. HOME PAGE&lt;/strong&gt;&lt;br&gt;
A home page serves as the landing page of your application, offering users an overview of the content or services you provide. In this guide, we'll create a simple yet effective home page using Next.js. This page will include a navigation bar, a hero section, and some content sections to give users a glimpse of what the site offers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. THE INVOICE PAGE&lt;/strong&gt;&lt;br&gt;
 An invoice page typically displays a list of items or services along with quantities, prices, and totals. In this guide, we will create a simple invoice page in Next.js, which includes an invoice list and summary. This example assumes static data for simplicity, but you can easily adapt it to fetch data from an API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. THE CUSTOMER PAGE&lt;/strong&gt;&lt;br&gt;
A customer page typically displays a list of customers along with relevant details like name, email, and contact information. This guide will walk you through creating a customer page in Next.js that fetches and displays customer data, and optionally allows actions like adding or deleting customers.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;WHAT I LEARNED&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learnt on how to create a Postgres database by creating new postgres then nevigated to the .env.local tab to show the secret and copied the snippet which is as follows;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POSTGRES_URL="postgres://default:yrq8tQa2bUDn@ep-rough-silence-a42bmnk3-pooler.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require"
POSTGRES_PRISMA_URL="postgres://default:yrq8tQa2bUDn@ep-rough-silence-a42bmnk3-pooler.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require&amp;amp;pgbouncer=true&amp;amp;connect_timeout=15"
POSTGRES_URL_NO_SSL="postgres://default:yrq8tQa2bUDn@ep-rough-silence-a42bmnk3-pooler.us-east-1.aws.neon.tech:5432/verceldb"
POSTGRES_URL_NON_POOLING="postgres://default:yrq8tQa2bUDn@ep-rough-silence-a42bmnk3.us-east-1.aws.neon.tech:5432/verceldb?sslmode=require"
POSTGRES_USER="default"
POSTGRES_HOST="ep-rough-silence-a42bmnk3-pooler.us-east-1.aws.neon.tech"
POSTGRES_PASSWORD="yrq8tQa2bUDn"
POSTGRES_DATABASE="verceldb"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Technical Article:For Django And NextJS.</title>
      <dc:creator>Denis Ogutu</dc:creator>
      <pubDate>Mon, 16 Sep 2024 13:51:32 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/technical-progress-report-django-and-nextjs-projectsoverview-nhm</link>
      <guid>https://dev.to/swahilipotdevs/technical-progress-report-django-and-nextjs-projectsoverview-nhm</guid>
      <description>&lt;p&gt;Overview&lt;/p&gt;

&lt;p&gt;A web application built with Django and a dashboard using Next.js have seen substantial development over the last two weeks. This document offers a thorough rundown of the environment configuration, development tasks, and significant connections with different project components.&lt;/p&gt;

&lt;p&gt;Environment Setup for Django Project&lt;/p&gt;

&lt;p&gt;Setup Python:&lt;/p&gt;

&lt;p&gt;The aim is to guarantee that Python is accessible for Django programming.&lt;br&gt;
Procedure: I downloaded Python's most recent version from the official website.&lt;br&gt;
PIP and Python may be accessed from the command line thanks to environment variable configuration.Setting up Django:&lt;/p&gt;

&lt;p&gt;Goal: Set up the web development framework Django.&lt;br&gt;
The process involved using pip to install Django.&lt;br&gt;
Confirming the installation was successful, I looked up the Django version.&lt;br&gt;
Checking the versions of Python and pip installed allowed for verification.&lt;br&gt;
Establishment and Configuration of Projects&lt;/p&gt;

&lt;p&gt;Project Start-Up:&lt;/p&gt;

&lt;p&gt;Goal: Start a brand-new Django project.&lt;br&gt;
Procedure: Using the Django command-line tool, create a new project called my_site.&lt;br&gt;
Result: The project structure was generated, together with necessary files like manage.py, urls.py, and settings.py.&lt;/p&gt;

&lt;p&gt;Making of an Application:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal: Expand the Django project by adding a new application.
Procedure: Developed a polls application inside the my_site project.
Result: The relevant files, models.py, views.py, forms.py, and urls.py, were added to the polls application directory.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Activities for Development&lt;/p&gt;

&lt;p&gt;Opinions&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal: Create views to manage queries and answers over the HTTP protocol.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Details: Views that connect with the database, process user input, and render templates have been implemented.&lt;/p&gt;

&lt;p&gt;Forms&lt;/p&gt;

&lt;p&gt;Control and verify user input is the goal.&lt;br&gt;
Details: Made forms that leverage Django's form handling features to manage user input and validation.&lt;/p&gt;

&lt;p&gt;URLs&lt;/p&gt;

&lt;p&gt;Setting up URL routing for the application is the goal.&lt;br&gt;
Details: Map URLs to certain view functionalities by configuring URL patterns.&lt;/p&gt;

&lt;p&gt;Configuration of Settings:&lt;/p&gt;

&lt;p&gt;Goal: Consolidate the new application inside the Django framework.&lt;br&gt;
Details: Added the polls app to the INSTALLED_APPS list by updating the settings.py file.&lt;/p&gt;

&lt;p&gt;Models:&lt;/p&gt;

&lt;p&gt;Goal: specify the structure of the database.&lt;br&gt;
Details: Fields and associations were defined, and models were created to reflect the database structure.&lt;/p&gt;

&lt;p&gt;Database Communication:&lt;/p&gt;

&lt;p&gt;Applying schema modifications to the database is the goal.&lt;br&gt;
Procedure: Created database tables based on the models and ran migrations using Django's ORM.&lt;br&gt;
Details: Commands to generate and apply migrations were executed, and the database schema was updated.&lt;/p&gt;

&lt;p&gt;Setup of the Next.js Project Environment&lt;/p&gt;

&lt;p&gt;Installing npm with Node.js:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal: Ascertain that npm and Node.js are accessible for developing Next.js.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Method: npm was installed together with Node.js from the official website.&lt;br&gt;
Verification: I checked the versions of Node.js and npm to confirm that they were installed.&lt;/p&gt;

&lt;p&gt;Installing pnpm:&lt;/p&gt;

&lt;p&gt;Goal: Make effective use of pnpm for package management.&lt;br&gt;
Procedure: Used npm to install pnpm globally.&lt;/p&gt;

&lt;p&gt;Establishing and Setting Up Projects&lt;/p&gt;

&lt;p&gt;Initialization of the Next.js Application:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal: Launch a fresh Next.js application.
Procedure: Using the create-next-app command, the my-nextjs-dashboard project was initially created.
Result: A brand-new Next.js project was built, complete with public assets, styles, configuration files, and folders for pages.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Vercel Implementation:&lt;/p&gt;

&lt;p&gt;Goal: Install the Next.js program on Vercel.&lt;br&gt;
Procedure: Continuous deployment and online access were made possible by using the Vercel CLI to deploy the application.&lt;/p&gt;

&lt;p&gt;Developmental Tasks&lt;/p&gt;

&lt;p&gt;Learning Platform for Next.js:&lt;/p&gt;

&lt;p&gt;First of all,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal: Become acquainted with Next.js via methodical education.
Activities: Finished the Next.js Learning Platform lessons on data fetching, routing, and API integration.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Adaptive Routing:&lt;/p&gt;

&lt;p&gt;Goal: Integrate dynamic routing into the program.&lt;br&gt;
Details: Configure dynamic routes to accommodate various post IDs and provide content that matches them.&lt;/p&gt;

&lt;p&gt;Fetching Data:&lt;/p&gt;

&lt;p&gt;Goal: Retrieve and show data from APIs.&lt;br&gt;
Details: To increase efficiency, static data fetching was implemented at build time.&lt;/p&gt;

&lt;p&gt;API Consolidation:&lt;/p&gt;

&lt;p&gt;Goal: Develop and incorporate APIs into the Next.js program.&lt;br&gt;
Specifics: Created a JSON response-returning API endpoint.&lt;/p&gt;

&lt;p&gt;Optimizing Performance:&lt;/p&gt;

&lt;p&gt;Improving application performance is the goal.&lt;br&gt;
Details: To increase load times and responsiveness, technologies including image optimization, code splitting, and caching were used.&lt;/p&gt;

&lt;p&gt;Testing&lt;/p&gt;

&lt;p&gt;Goal: Verify the application's dependability.&lt;br&gt;
Tools: For unit testing, Jest was used.&lt;br&gt;
Details: Tests were created and run to ensure that functionality and component rendering were accurate.&lt;/p&gt;

&lt;p&gt;In summary&lt;/p&gt;

&lt;p&gt;Both the Next.js and Django projects have made significant development in the last two weeks. Creating and establishing a project and application, as well as generating essential components like views, forms, URLs, and models, were all part of the Django project. The Next.js project concentrated on configuring the environment, starting the program, deploying it to Vercel, and putting capabilities like data fetching, dynamic routing, API integration, and performance optimization into practice. The underlying components of both projects have been developed, and the key features have been tested and put into practice.&lt;/p&gt;

&lt;p&gt;Article banner image&lt;br&gt;
code snippets&lt;br&gt;
Python macdown&lt;/p&gt;

</description>
    </item>
    <item>
      <title>example</title>
      <dc:creator>liz nzisa</dc:creator>
      <pubDate>Mon, 16 Sep 2024 13:50:07 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/example-44kh</link>
      <guid>https://dev.to/swahilipotdevs/example-44kh</guid>
      <description></description>
    </item>
    <item>
      <title>Building a Simple Polling App in Django: Step-by-Step Guide</title>
      <dc:creator>Maskini Mnene</dc:creator>
      <pubDate>Mon, 16 Sep 2024 13:48:53 +0000</pubDate>
      <link>https://dev.to/swahilipotdevs/technical-synopsis-activities-finalised-during-the-last-two-weeks-4738</link>
      <guid>https://dev.to/swahilipotdevs/technical-synopsis-activities-finalised-during-the-last-two-weeks-4738</guid>
      <description>&lt;p&gt;We will go through setting up a Django project from scratch to create a simple polling application. This guide will cover everything from installing Python and Django to configuring your app with models, views, and templates. Along the way, we will build a feature that lets users vote in a poll, and we will explore key concepts like generic views, models, and URL routing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Installing Python and Setting Up a Virtual Environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before you start with Django, make sure you have Python installed on your machine. If you don’t have it installed, you can download Python from python.org.&lt;/p&gt;

&lt;p&gt;To keep your project’s dependencies isolated, it’s best to use a virtual environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Install virtualenv if you don't have it
pip install virtualenv

# Create a virtual environment
virtualenv venv

# Activate the virtual environment
venv\Scripts\activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Installing Django and Starting a Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With your virtual environment activated, install Django:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install django
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, create a new Django project called mysite:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;django-admin startproject mysite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a mysite directory that contains your project files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Creating the Polls App&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Django follows a modular approach, and every feature in Django is usually built inside an "app". We will create an app called polls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd mysite
python manage.py startapp polls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, register the polls app in mysite/settings.py by adding it to the INSTALLED_APPS list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSTALLED_APPS = [
    # other apps...
    'polls',
]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Defining Models for Questions and Choices&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In polls/models.py, we will define two models: Question and Choice. Each Question will have several Choices that users can vote on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.db import models
from django.utils import timezone
import datetime

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def __str__(self):
        return self.question_text

    def was_published_recently(self):
        now = timezone.now()
        return now - datetime.timedelta(days=1) &amp;lt;= self.pub_date &amp;lt;= now

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

    def __str__(self):
        return self.choice_text

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Creating and Migrating the Database&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will be using SQLite for our database, which is the default for Django. The configuration can be found in mysite/settings.py under the DATABASES section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After setting up the models, you need to generate the migrations and apply them to create the database schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py makemigrations
python manage.py migrate

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6: Creating Views for Polls&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will use Django’s generic views to simplify the process of creating list and detail views. In polls/views.py, define views for listing questions, showing details of a question, and displaying results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.db.models import F
from django.views import generic
from django.utils import timezone
from .models import Question, Choice

class IndexView(generic.ListView):
    template_name = 'polls/index.html'
    context_object_name = 'latest_question_list'

    def get_queryset(self):
        return Question.objects.filter(pub_date__lte=timezone.now()).order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
    model = Question
    template_name = 'polls/detail.html'

    def get_queryset(self):
        return Question.objects.filter(pub_date__lte=timezone.now())

class ResultsView(generic.DetailView):
    model = Question
    template_name = 'polls/results.html'

def vote(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
    try:
        selected_choice = question.choice_set.get(pk=request.POST['choice'])
    except (KeyError, Choice.DoesNotExist):
        return render(request, 'polls/detail.html', {
            'question': question,
            'error_message': "You didn't select a choice.",
        })
    else:
        selected_choice.votes = F('votes') + 1
        selected_choice.save()
        return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 7: Mapping URLs to Views&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In polls/urls.py, define the URL patterns for our app, which will map the URL paths to the views we just created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path
from . import views

app_name = 'polls'
urlpatterns = [
    path('', views.IndexView.as_view(), name='index'),
    path('&amp;lt;int:pk&amp;gt;/', views.DetailView.as_view(), name='detail'),
    path('&amp;lt;int:pk&amp;gt;/results/', views.ResultsView.as_view(), name='results'),
    path('&amp;lt;int:question_id&amp;gt;/vote/', views.vote, name='vote'),
]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, include the polls/urls.py in the main mysite/urls.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('polls/', include('polls.urls')),
    path('admin/', admin.site.urls),
]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 8: Creating Templates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In polls/templates/polls/, create the HTML templates. First, index.html will display the list of questions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{% load static %}

&amp;lt;link rel="stylesheet" href="{% static 'polls/style.css' %}"&amp;gt;

{% if latest_question_list %}
    &amp;lt;ul&amp;gt;
    {% for question in latest_question_list %}
        &amp;lt;li&amp;gt;&amp;lt;a href="{% url 'polls:detail' question.id %}"&amp;gt;{{ question.question_text }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; 
    {% endfor %}
    &amp;lt;/ul&amp;gt;
{% else %}
    &amp;lt;p&amp;gt;No polls are available.&amp;lt;/p&amp;gt;
{% endif %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, the detail.html template will display the voting form for a question:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;{{ question.question_text }}&amp;lt;/h1&amp;gt;
&amp;lt;form action="{% url 'polls:vote' question.id %}" method="post"&amp;gt;
    {% csrf_token %}
    {% for choice in question.choice_set.all %}
        &amp;lt;input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}"&amp;gt;
        &amp;lt;label for="choice{{ forloop.counter }}"&amp;gt;{{ choice.choice_text }}&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    {% endfor %}
    &amp;lt;input type="submit" value="Vote"&amp;gt;
&amp;lt;/form&amp;gt;
{% if error_message %}&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;{{ error_message }}&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;{% endif %}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, results.html will display the voting results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;{{ question.question_text }}&amp;lt;/h1&amp;gt;

&amp;lt;ul&amp;gt;
{% for choice in question.choice_set.all %}
    &amp;lt;li&amp;gt;{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}&amp;lt;/li&amp;gt;
{% endfor %}
&amp;lt;/ul&amp;gt;

&amp;lt;a href="{% url 'polls:detail' question.id %}"&amp;gt;Vote again?&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 9: Running the Development Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that everything is set up, you can start the Django development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py runserver

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
