Skip to content

sipe-team/sipethon-2_5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2-5

Routing Structure

/ 이면 /routine 으로 redirecting

  • /timer
    • result
  • /routine (main)
    • [id] (id에 어떤 값이 올지는 개발하면서 결정)
  • /history
    • [id] (id에 어떤 값이 올지는 개발 하면서 결정)
  • /profile
  • /login

how to routing in nextjs (based app route)

Redirection

import { redirect } from "next/navigation"; // server component에서만 사용 가능

const Home = () => {
  redirect("/routine"); // redirect to /routine
};

export default Home;

Push / Backward

"use client";
import { useRouter } from "next/navigation";

const Home = () => {
  const router = useRouter();

  const handleClick = () => {
    router.push("/routine");
  };

  const handleBack = () => {
    router.back();
  };

  return (
    <div>
      <button onClick={handleClick}>Go to Routine</button>
      <button onClick={handleBack}>Back</button>
    </div>
  );
};

export default Home;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published