I am experiencing issues with the Link component in Next.js version 13.4, as it

Whenever I attempt to navigate by clicking on the buttons labeled About, Experience, and others, the page does not redirect me accordingly. Oddly enough, if I manually input the endpoint for that specific page like http://localhost:3000/#about, it functions properly. So why is it that my button fails to take me there when the designated section exists? Below you'll find the relevant code snippet.

import { Cursor, useTypewriter } from 'react-simple-typewriter';
import Image from 'next/image';
import React from 'react'
import BackgroundCircles from './BackgroundCircles';
import imageofme from '../public/imageofme.png';
import Link from 'next/link';

type Props = {}

export default function Hero({}: Props) {
  const [text,count] = useTypewriter({
    words: ['Hello World', 'Welcome to my website', 'I am a web developer'],
    loop: true,
  delaySpeed: 2000,
  })

  return (
    <div className='h-screen flex flex-col space-y-8 items-center justify-center
    text-center overflow-hidden'>
      <BackgroundCircles/>
      <Image className='relative rounded-fill h32 w-32 mx-auto object-cover'
      src={imageofme} 
      alt='image of me' />
      <div className='z-20'>
        <h2 className='text-sm uppercase text-gray-500 pb-2 tracking-[15px]'>
        Junior Software Developer
        </h2>
      <h1 className='text-5xl lg:text-6xl font-semibold px-10'>
      <span className='mr-3'>{text}</span>
      <Cursor cursorColor='black'/>
      </h1>
      <div className='pt-5'>
        <Link href='#about'>
        <button className='heroButton'>About</button>
        </Link>
        <Link href='#experience'>
        <button className='heroButton'>Experience</button>
        </Link>
        <Link href='#skills'>
        <button className='heroButton'>Skills</button>
        </Link>
        <Link href='#projects'>
        <button className='heroButton'>Projects</button>
        </Link>
      </div>
      </div>
    </div>
  )
}


Page.tsx 

'use client'
import About from "@/components/About";
import Experience from "@/components/Experience";
import Header from "@/components/Header";
import Hero from "@/components/Hero";


export default function Home() {
  return (
    < div className='bg-[rgb(55,64,104)] text-white h-screen snap-y snap-mandatory 
    overflow-scroll z-0' >
<Header/>

<section id='hero' className='snap-center'>
<Hero/>
</section>


<section id='about' className='snap-center'>
<About/>
</section>


{/*experience */}
<section id='experience' className="snap-center">
  <Experience/>
</section>

{/*skills*/}

{/*projects */}

{/*Contact Me */}

</div>
  )
}

Even after diligently following the documentation and inspecting the console for any errors, the issue persists. I've also experimented with using Next links that did not yield positive results, and modified the paths to be / instead of # without success.

Answer №1

To create a hyperlink in HTML, simply use the anchor tag like this:

<a href="#about">Text</a>

Keep in mind that using next/link is specifically for navigating between pages within Next.js.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Custom React components are not designed to handle multiple onClick events simultaneously

One of my custom button components looks like this: export const Button = ({ children, onClick, className, ...props }: IButton) { const [selected, setSelected] = React.useState('primary') const handleSelected = () => { setSele ...

The Material-UI Style is malfunctioning, receiving a warning that the prop `className` does not match on the server

Having trouble with style not displaying correctly while using Material-ui with Next.js. Encountering the following warning: "Warning: Prop className did not match. Server:" I referenced the example for Next.js With Material-ui from here. Environmen ...

How does TypeScript provide me with insights even before compiling with tsc?

As I follow the instructions for incorporating TypeScript into my existing React Native project here, the final step instructs me to: Run yarn tsc to type-check your new TypeScript files. However, when I check VSCode, I am already receiving feedback from ...

What is the process for creating a new element and utilizing its reference to add child elements in React?

I've been struggling to create an HTML element in a parent component in React, and then access that component's div from a child component in order to add new elements to it. Despite multiple attempts, I can't seem to resolve the issue of p ...

Using a specific type of keys, attempting to set two instances of those keys simultaneously will result in an error of that type

Consider this scenario: type Example = { x: string, y: number } const a: Example = { x: "x", y: 1 } const b: Example = { x: "y", y: 2 } const issue = (keys: (keyof Example)[]) => { keys.forEach(key => { a[key] ...

Ways to abbreviate a URL using Next JS

While working on my Next.js application, I encountered an issue with passing an object between pages. To achieve this, I compressed my array of objects into JSON using JSON.stringify(result) on the index page and then parsed it on the second page using JSO ...

How to utilize Enzyme to call a React prop in TypeScript

I'm currently in the process of converting my Jest tests from Enzyme to TypeScript, and I've come across a specific case that I'm unsure how to resolve. Essentially, I'm attempting to invoke a function passed as a prop to a sub-componen ...

What strategies can be implemented to maximize the efficiency of Firebase when designing an admin-only page, in order to minimize unnecessary data reads and

Currently, I have established a secure page within our website that is exclusively accessible to administrators. The technology stack being used includes React Next.js and Cloud Firestore for managing data. As the page is loaded, a read operation in Firest ...

What is the importance of including "declare var angular" while working with Typescript and AngularJS?

I've been working on an AngularJS 1.7 application that's coded entirely in TypeScript, and there's always been one thing bothering me. Within my app.module.ts file, I have this piece of code that doesn't sit right with me: declare va ...

Issue: ReactJS - $npm_package_version variable not functioning properly in build versionIn the current

After trying this suggested solution, unfortunately, it did not work for my specific case. The React application I am working on was initialized with CRA version 5.0.1 and currently has a version of 18.2.0. Additionally, the dotenv version being used is 1 ...

Error: The nested property of the dynamic type cannot be indexed

Within my coding project, I've devised an interface that includes various dynamic keys for API routes, along with the corresponding method and response structure. interface ApiRoutes { "auth/login": { POST: { response: { ...

Alter the style type of a Next.js element dynamically

I am currently working on dynamically changing the color of an element based on the result of a function //Sample function if ("123".includes("5")) { color = "boldOrange" } else { let color = "boldGreen" } Within my CSS, I have two clas ...

Top Tips for Safely Storing User Access Tokens

Presently, I am in the process of developing a medical health-focused system utilizing nextjs for the frontend and Django for the backend. Within my application, I have implemented React-Redux to securely store user access tokens post successful authenti ...

A guide to updating a table in Angular using an API response

My form allows me to select events from a drop-down list and choose a date. Depending on the selected date, it retrieves the number of events that occurred on that specific date. If I select an event and a date where events took place, the "All Events" sec ...

Tips for obtaining the full URL when deploying a Next.js website on Vercel

In order for my Next.js websites to function properly, they rely on the Next.js APIs to fetch data from a local JSON file. I am utilizing getStaticPaths to pre-generate pages. The issue I am encountering is that it only supports absolute paths, which works ...

Navigating through pages: How can I retrieve the current page value for implementing next and previous functions in Angular 7?

Greetings, I am a new learner of Angular and currently working on custom pagination. However, I am facing difficulty in finding the current page for implementing the next and previous functions. Can anyone guide me on how to obtain the current page value? ...

Can you explain the distinction between using keyof within an indexer versus outside of it?

Consider the TypeScript snippet below: type ForwardVal<T> = { [K in keyof T]: string; }; type ForwardKeyOf<T extends string | number | symbol> = { [K in T]: string; }; type ByObj = ForwardVal<number[]>; // string[] ...

What is the proper way to send a list as a parameter in a restangular post request

Check out this code snippet I found: assignUserToProject(pid: number, selectedUsers: any, uid: number) { let instance = this; return instance.Restangular.all("configure/assign").one(pid.toString()).one(uid.toString()).post(selectedUsers); } ...

Encountering a Typescript issue when trying to access props.classes in conjunction with material-ui, react-router-dom

I could really use some help with integrating material-ui's theming with react-router-dom in a Typescript environment. I'm running into an issue where when trying to access classes.root in the render() method, I keep getting a TypeError saying &a ...

This function has a Cyclomatic Complexity of 11, exceeding the authorized limit of 10

if ((['ALL', ''].includes(this.accountnumber.value) ? true : ele.accountnumber === this.accountnumber.value) && (['ALL', ''].includes(this.description.value) ? true : ele.description === this.description.valu ...