Next.js Discord

Discord Forum

get router paths separately?

Answered
piscopancer posted this in #help-forum
Open in Discord
Answered by alfon
import { Route } from "next";
View full answer

16 Replies

not possible?
its in the Route type you don't have to use typeof router.push...
how do I access this type?
import { Route } from "next";
Answer
for some reason it does not support dynamic routes
    const surveyLinks = {
        created: {
            icon: BiUser,
            text: 'Созданные',
            path: '/surveys/created',
        },
        liked: {
            icon: BiHeart,
            text: 'Любимые',
            path: '/surveys/liked',
        },
        community: {
            icon: BiGlobe,
            text: 'От сообщества',
            path: `/surveys/community/page/${communitySurveys.page}`,
        },
    } satisfies Record<string, {icon: IconType; text: string; path: Route}>
a temporary solution as following
    const surveyLinks = {
        created: {
            icon: BiUser,
            text: 'Созданные',
            path: '/surveys/created',
        },
        liked: {
            icon: BiHeart,
            text: 'Любимые',
            path: '/surveys/liked',
        },
        community: {
            icon: BiGlobe,
            text: 'От сообщества',
            path: `/surveys/community/page/${communitySurveys.page}`,
        },
    } satisfies Record<string, {icon: IconType; text: string; path: Route | `/surveys/community/page/${number}`}>
@piscopancer Click to see attachment
sometimes it works sometimes it doesn't?
bruh
oh its a qeustion
i mean
you might want to npm run dev it first?
sometimes it catches on all the routes and sometimes it just throw ts error
i am having it run all the time but I will try to restart it ok