npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nextjs-assistant

v0.25.0

Published

The Next.js Assistant, your ultimate resource for Next.js development.

Downloads

35

Readme

Next.js Assistant

Build for Production. Designed for Developers.

Visual Studio Marketplace Installs Visual Studio Marketplace Downloads Visual Studio Marketplace Rating

Project just started. Will take some time to get it to a good place. Please be patient.

Links

  • https://github.com/nrjdalal/next.js-assistant
  • https://marketplace.visualstudio.com/items?itemName=nrjdalal.nextjs-assistant

Introduction

Welcome to the Next.js Assistant, your ultimate resource for Next.js development. This project offers a curated collection of snippets, templates, and resources designed to streamline your Next.js application development process.

Contributing

This is a contribution first project. Therefore I made it as easy as possible to contribute.

We welcome contributions from everyone. Adding snippets to this project is straightforward—just edit the MAIN.md file. Simply add amazing snippets to the relevant section and submit a pull request.

Getting Started

To begin, simply install the extension from the Visual Studio Code Marketplace. You can access it here. Once installed, you can immediately start utilizing the provided snippets to enhance your development workflow.

Table of Contents

| Snippets | Description | | ----------------------------------------- | ------------------------------------ | | Directives | | | use-cache | 🔥 use cache 🔥 | | use-client | 🔥 use client 🔥 | | use-server | 🔥 use server 🔥 | | Components | | | Image | | | import-image | 🔥 Image Import 🔥 | | image | 🔥 Image 🔥 | | Link | | | import-link | 🔥 Link Import 🔥 | | link | 🔥 Link 🔥 | | link-with-target-blank | 🔥 Link with Target Blank 🔥 | | Script | | | import-script | 🔥 Script Import 🔥 | | script | 🔥 Script 🔥 | | File Conventions | | | error.tsx | | | export-error | 🔥 Error 🔥 | | layout.tsx | | | export-layout | 🔥 Layout 🔥 | | export-root-layout | 🔥 Root Layout 🔥 | | page.tsx | | | export-page | 🔥 Page 🔥 | | export-page-with-params | 🔥 Page with Params 🔥 | | export-page-with-searchParams | 🔥 Page with Search Params 🔥 | | export-page-with-client-params | 🔥 Page with Client Params 🔥 | | export-page-with-client-searchParams | 🔥 Page with Client Search Params 🔥 | | route.ts | | | export-async-get | 🔥 GET Request 🔥 | | export-async-post | 🔥 POST Request 🔥 | | export-async-put | 🔥 PUT Request 🔥 | | export-async-patch | 🔥 PATCH Request 🔥 | | export-async-delete | 🔥 DELETE Request 🔥 | | export-async-get-with-cookies | 🔥 GET Request with Cookies 🔥 | | export-async-post-with-cookies | 🔥 POST Request with Cookies 🔥 | | export-async-put-with-cookies | 🔥 PUT Request with Cookies 🔥 | | export-async-patch-with-cookies | 🔥 PATCH Request with Cookies 🔥 | | export-async-delete-with-cookies | 🔥 DELETE Request with Cookies 🔥 | | export-async-get-with-headers | 🔥 GET Request with Headers 🔥 | | export-async-post-with-headers | 🔥 POST Request with Headers 🔥 | | export-async-put-with-headers | 🔥 PUT Request with Headers 🔥 | | export-async-patch-with-headers | 🔥 PATCH Request with Headers 🔥 | | export-async-delete-with-headers | 🔥 DELETE Request with Headers 🔥 | | Configuration | | | next-config-ts | 🔥 Next Config 🔥 | | Drizzle | | | drizzle-config | 🔥 Drizzle Config 🔥 | | drizzle-schema | 🔥 Drizzle Schema 🔥 |

Roadmap

Roadmap Extras

  • [ ] Drizzle
  • [ ] Prettier
  • [ ] React Hook Form
  • [ ] Shadcn
  • [ ] Tanstack Query
  • [ ] Zod

Directives

use cache

// use-cache - 🔥 use cache 🔥 //

"use cache"

use client

// use-client - 🔥 use client 🔥 //

"use client"

use server

// use-server - 🔥 use server 🔥 //

"use server"

Components

Image

  • Image Import

// import-image - 🔥 Image Import 🔥 //

import Image from "next/image"
  • Image Component

// image - 🔥 Image 🔥 //

<Image src="/nrjdalal.png" width={500} height={500} alt="Author Photo" />

Link

  • Link Import

// import-link - 🔥 Link Import 🔥 //

import Link from "next/link"
  • Link Component

// link - 🔥 Link 🔥 //

<Link href="/">Home</Link>
  • Link Component with Target Blank

// link-with-target-blank - 🔥 Link with Target Blank 🔥 //

<Link href="/" target="_blank">
  Home
</Link>

Script

  • Script Import

// import-script - 🔥 Script Import 🔥 //

import Script from "next/script"
  • Script Component

// script - 🔥 Script 🔥 //

<Script src="https://example.com/script.js" />

File Conventions

error.tsx

// export-error - 🔥 Error 🔥 //

"use client"

import { useEffect } from "react"

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string }
  reset: () => void
}) {
  useEffect(() => {
    // Log the error to an error reporting service
    console.error(error)
  }, [error])

  return (
    <div
      style={{
        minHeight: "100dvh",
        display: "flex",
        flexDirection: "column",
        alignItems: "center",
        justifyContent: "center",
      }}
    >
      <h2>Something went wrong!</h2>
      <button
        onClick={
          // Attempt to recover by trying to re-render the segment
          () => reset()
        }
      >
        Try again
      </button>
    </div>
  )
}

layout.tsx

  • Layout

// export-layout - 🔥 Layout 🔥 //

export default function Layout({ children }: { children: React.ReactNode }) {
  return <>{children}</>
}
  • Root Layout

// export-root-layout - 🔥 Root Layout 🔥 //

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}

page.tsx

  • Page

// export-page - 🔥 Page 🔥 //

export default function Page() {
  return <>x.com/nrjdalal_com</>
}
  • Page with Params

// export-page-with-params - 🔥 Page with Params 🔥 //

export default async function Page({
  params,
}: {
  params: Promise<{ slug: string }>
}) {
  const slug = (await params).slug

  return <>{slug}</>
}
  • Page with Search Params

// export-page-with-searchParams - 🔥 Page with Search Params 🔥 //

export default async function Page({
  searchParams,
}: {
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}) {
  const { query } = await searchParams

  return <>{query}</>
}
  • Page with Client Params

// export-page-with-client-params - 🔥 Page with Client Params 🔥 //

"use client"

import { use } from "react"

export default function Page({
  params,
}: {
  params: Promise<{ slug: string }>
}) {
  const { slug } = use(params)

  return <>{slug}</>
}
  • Page with Client Search Params

// export-page-with-client-searchParams - 🔥 Page with Client Search Params 🔥 //

"use client"

import { use } from "react"

export default function Page({
  searchParams,
}: {
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}) {
  const { query } = use(searchParams)

  return <>{query}</>
}

route.ts

  • GET

// export-async-get - 🔥 GET Request 🔥 //

export async function GET(request: Request) {
  try {
    const query = Object.fromEntries(new URL(request.url).searchParams)

    // ${0:console.log(query)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • POST

// export-async-post - 🔥 POST Request 🔥 //

export async function POST(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • PUT

// export-async-put - 🔥 PUT Request 🔥 //

export async function PUT(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • PATCH

// export-async-patch - 🔥 PATCH Request 🔥 //

export async function PATCH(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • DELETE

// export-async-delete - 🔥 DELETE Request 🔥 //

export async function DELETE(request: Request) {
  try {
    const query = Object.fromEntries(new URL(request.url).searchParams)

    // ${0:console.log(query)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • GET Request with Cookies

// export-async-get-with-cookies - 🔥 GET Request with Cookies 🔥 //

import { cookies } from "next/headers"

export async function GET(request: Request) {
  try {
    const query = Object.fromEntries(new URL(request.url).searchParams)

    // ${0:console.log(await cookies(), query)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • POST Request with Cookies

// export-async-post-with-cookies - 🔥 POST Request with Cookies 🔥 //

import { cookies } from "next/headers"

export async function POST(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(await cookies(), body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • PUT Request with Cookies

// export-async-put-with-cookies - 🔥 PUT Request with Cookies 🔥 //

import { cookies } from "next/headers"

export async function PUT(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(await cookies(), body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • PATCH Request with Cookies

// export-async-patch-with-cookies - 🔥 PATCH Request with Cookies 🔥 //

import { cookies } from "next/headers"

export async function PATCH(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(await cookies(), body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • DELETE Request with Cookies

// export-async-delete-with-cookies - 🔥 DELETE Request with Cookies 🔥 //

import { cookies } from "next/headers"

export async function DELETE(request: Request) {
  try {
    const query = Object.fromEntries(new URL(request.url).searchParams)

    // ${0:console.log(await cookies(), query)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • GET Request with Headers

// export-async-get-with-headers - 🔥 GET Request with Headers 🔥 //

import { headers } from "next/headers"

export async function GET(request: Request) {
  try {
    const query = Object.fromEntries(new URL(request.url).searchParams)

    // ${0:console.log(await headers(), query)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • POST Request with Headers

// export-async-post-with-headers - 🔥 POST Request with Headers 🔥 //

import { headers } from "next/headers"

export async function POST(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(await headers(), body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • PUT Request with Headers

// export-async-put-with-headers - 🔥 PUT Request with Headers 🔥 //

import { headers } from "next/headers"

export async function PUT(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(await headers(), body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • PATCH Request with Headers

// export-async-patch-with-headers - 🔥 PATCH Request with Headers 🔥 //

import { headers } from "next/headers"

export async function PATCH(request: Request) {
  try {
    const body = await request.json()

    // ${0:console.log(await headers(), body)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}
  • DELETE Request with Headers

// export-async-delete-with-headers - 🔥 DELETE Request with Headers 🔥 //

import { headers } from "next/headers"

export async function DELETE(request: Request) {
  try {
    const query = Object.fromEntries(new URL(request.url).searchParams)

    // ${0:console.log(await headers(), query)}

    return Response.json({ message: "OK" }, { status: 200 })
  } catch (error: unknown) {
    console.log(error)
    if (error instanceof Error) {
      return Response.json({ message: error.message }, { status: 404 })
    } else {
      return Response.json({ message: "404" }, { status: 404 })
    }
  }
}

Configuration

// next-config-ts - 🔥 Next Config 🔥 //

import type { NextConfig } from "next"

const nextConfig: NextConfig = {
  /* config options here */
}

export default nextConfig

Drizzle

  • Drizzle Config

// drizzle-config - 🔥 Drizzle Config 🔥 //

import { defineConfig } from "drizzle-kit"

export default defineConfig({
  dialect: "postgresql",
  dbCredentials: {
    url: process.env.POSTGRES_URL!,
  },
  schema: "./src/db",
  out: "./src/db/drizzle",
})
  • Drizzle Schema

// drizzle-schema - 🔥 Drizzle Schema 🔥 //

import { drizzle, type PostgresJsDatabase } from "drizzle-orm/postgres-js"
import postgres from "postgres"

declare global {
  // eslint-disable-next-line
  var db: PostgresJsDatabase
}

let db: PostgresJsDatabase

if (process.env.NODE_ENV === "production") {
  db = drizzle({
    client: postgres(process.env.POSTGRES_URL!, {
      connect_timeout: 10000,
      idle_timeout: 30000,
      ssl: {
        rejectUnauthorized: true,
      },
    }),
  })
} else {
  if (!global.db) {
    global.db = drizzle({
      client: postgres(process.env.POSTGRES_URL!, {
        connect_timeout: 10000,
        idle_timeout: 30000,
      }),
    })
  }
  db = global.db
}

export { db }