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

@avicennateknoloji/next-centralized-link

v0.0.1

Published

Next.js için merkezileştirilmiş link yönetimi - route tanımlarını tek yerden yönetmek için kullanılır

Downloads

7

Readme

Next.js Centralized Link

Next.js projelerinde route tanımlarını merkezileştirilmiş bir şekilde yönetmek için kullanılan TypeScript paketi.

🚀 Kurulum

npm install @avicennateknoloji/next-centralized-link
yarn add @avicennateknoloji/next-centralized-link
pnpm add @avicennateknoloji/next-centralized-link

📖 Kullanım

Temel Kullanım

import { centralizedLink, getLink } from '@avicennateknoloji/next-centralized-link';

// Route tanımları
centralizedLink('home', () => '/');
centralizedLink('about', () => '/about');
centralizedLink('contact', () => '/contact');

// Link kullanımı
const homeUrl = getLink('home'); // '/'
const aboutUrl = getLink('about'); // '/about'

Parametreli Route'lar

import { centralizedLink, getLink } from '@avicennateknoloji/next-centralized-link';

// Parametreli route tanımları
centralizedLink('user', ({ id }) => `/user/${id}`);
centralizedLink('post', ({ slug }) => `/blog/${slug}`);
centralizedLink('category', ({ category, page = 1 }) => `/category/${category}?page=${page}`);

// Kullanım
const userUrl = getLink('user', { id: 123 }); // '/user/123'
const postUrl = getLink('post', { slug: 'my-post' }); // '/blog/my-post'
const categoryUrl = getLink('category', { category: 'tech', page: 2 }); // '/category/tech?page=2'

Next.js Link Component'i ile Kullanım

import Link from 'next/link';
import { getLink } from '@avicennateknoloji/next-centralized-link';

function Navigation() {
  return (
    <nav>
      <Link href={getLink('home')}>Ana Sayfa</Link>
      <Link href={getLink('about')}>Hakkında</Link>
      <Link href={getLink('user', { id: 123 })}>Kullanıcı Profili</Link>
    </nav>
  );
}

Router ile Kullanım

import { useRouter } from 'next/router';
import { getLink } from '@avicennateknoloji/next-centralized-link';

function MyComponent() {
  const router = useRouter();
  
  const handleNavigation = () => {
    router.push(getLink('user', { id: 456 }));
  };
  
  return (
    <button onClick={handleNavigation}>
      Kullanıcı Profiline Git
    </button>
  );
}

🔧 API Referansı

centralizedLink(key, linkFunction)

Yeni bir route tanımı ekler.

Parametreler:

  • key (string): Route'un benzersiz anahtarı
  • linkFunction (function): Route'u oluşturan fonksiyon

Örnek:

centralizedLink('user', ({ id }) => `/user/${id}`);

getLink(key, params?)

Tanımlanan route'u alır.

Parametreler:

  • key (string): Route anahtarı
  • params (object, opsiyonel): Route parametreleri

Döndürür: string - Route URL'si

Örnek:

const url = getLink('user', { id: 123 }); // '/user/123'

hasLink(key)

Belirli bir route'un tanımlı olup olmadığını kontrol eder.

Parametreler:

  • key (string): Route anahtarı

Döndürür: boolean

Örnek:

const exists = hasLink('user'); // true veya false

getDefinedLinks()

Tüm tanımlanan route'ları listeler.

Döndürür: string[] - Tanımlanan route anahtarları

Örnek:

const allLinks = getDefinedLinks(); // ['home', 'about', 'user', ...]

💡 Örnekler

E-ticaret Sitesi Route'ları

import { centralizedLink, getLink } from '@avicennateknoloji/next-centralized-link';

// Route tanımları
centralizedLink('home', () => '/');
centralizedLink('products', () => '/products');
centralizedLink('product', ({ id }) => `/product/${id}`);
centralizedLink('category', ({ slug }) => `/category/${slug}`);
centralizedLink('cart', () => '/cart');
centralizedLink('checkout', () => '/checkout');
centralizedLink('user', ({ id }) => `/user/${id}`);
centralizedLink('orders', ({ userId }) => `/user/${userId}/orders`);

// Kullanım örnekleri
const productUrl = getLink('product', { id: 'abc123' }); // '/product/abc123'
const categoryUrl = getLink('category', { slug: 'electronics' }); // '/category/electronics'
const ordersUrl = getLink('orders', { userId: 456 }); // '/user/456/orders'

Blog Route'ları

centralizedLink('blog', () => '/blog');
centralizedLink('post', ({ slug }) => `/blog/${slug}`);
centralizedLink('author', ({ username }) => `/author/${username}`);
centralizedLink('tag', ({ tag }) => `/tag/${tag}`);
centralizedLink('archive', ({ year, month }) => `/archive/${year}/${month}`);

// Kullanım
const postUrl = getLink('post', { slug: 'nextjs-tips' }); // '/blog/nextjs-tips'
const authorUrl = getLink('author', { username: 'johndoe' }); // '/author/johndoe'
const archiveUrl = getLink('archive', { year: 2023, month: 12 }); // '/archive/2023/12'

🛡️ TypeScript Desteği

Bu paket tam TypeScript desteği ile gelir:

import type { RouteParams, CentralizedLinkFunction } from '@avicennateknoloji/next-centralized-link';

// Tip güvenli route tanımları
const userRoute: CentralizedLinkFunction = ({ id }: RouteParams) => `/user/${id}`;
centralizedLink('user', userRoute);

🎯 Avantajlar

  • Merkezileştirilmiş Yönetim: Tüm route'lar tek yerden yönetilir
  • Tip Güvenliği: Full TypeScript desteği
  • Kolay Refaktoring: Route değişiklikleri tek yerden yapılır
  • Hata Azaltma: Yanlış URL yazma riskini minimuma indirir
  • Next.js Uyumluluğu: Hem App Router hem Pages Router ile uyumlu

📄 Lisans

MIT

🤝 Katkıda Bulunma

Katkılarınızı bekliyoruz! Lütfen pull request göndermeden önce issue açın.


Bu paket Next.js projelerinde route yönetimini kolaylaştırmak için tasarlanmıştır. Herhangi bir sorunuz varsa issue açmaktan çekinmeyin!