Next.jsisanopen-sourceJavaScriptframeworkthatisbuilton'(top of React)',apopularJavaScriptlibraryforbuildinguserinterfaces.Itisdesignedtomakeiteasiertocreate'(server-rendered)'Reactapplicationswithafocusondeveloperproductivity,performance,andSEO(SearchEngineOptimization).Next.jsprovidesasetoftoolsandconventionsthatsimplifyvariousaspectsofbuildingwebapplications.
1.'(Page-Based Structure)': Theapplicationfollowsapage-basedstructure,whereeachpagecorrespondstoafileinthe"pages"folderwithintheprojectdirectory.Thisleadstoautomaticroutegeneration.2.'(Server-Side Rendering (SSR))': Next.jsfacilitatesserver-siderendering,meaningthatpagesaregeneratedontheserverandthensenttotheuser.Thisresultsinfasterinitialpageloadsandimprovessearchengineoptimization(SEO).3.'(Client-Side Routing)': Transitionsbetweenpagesarehandledthroughclient-siderouting,makingpagetransitionsfastersincethecontentisdynamicallyloadedontheclientside.4.'(API Routes)': Next.jsprovidesamechanismforcreatingsimpleAPIroutesthatrunontheserverside.5.'(Data Fetching and Prefetching)': Next.jsallowsdeveloperstomanagedatafetchingeitherduringthepageloadorwhenauserclicksonalink,withsupportforprefetchingdatatoenhanceperformance.6.'(Modular Structure)': Next.jsfollowsamodularstructure,includingasetofpredefinedfeaturesthatmakeapplicationdevelopmentfasterandmoreefficient.7.'(Static Site Generation (SSG))': Next.jssupportsstaticsitegeneration,allowingpagestobecompiledandservedasstaticfiles,offeringperformanceandscalabilitybenefits.8.'(Automatic Code Splitting)': Next.jsautomaticallysplitscodeintosmallerparts,loadingonlythenecessarycomponents,resultinginfasterloadingtimes.9.'(Customizable Head Element)': Itprovidesaneasywaytocustomizetheheadelementofeachpage,allowingdeveloperstosettitles,metatags,andotherheaderelements.10.'(TypeScript Support)': Next.jssupportsTypeScript,providingdeveloperswithstatictypingforenhancedsafetyandcodereadability.Next.jsenablesdeveloperstobuildscalableandperformantwebapplicationsquickly.Itsfeaturesmakeitwell-suitedforvarioususecases,includingstaticwebsites,dynamicwebapplications,andevenserverlessapplications.TheframeworkiswidelyadoptedintheReactecosystemandisknownforitseaseofuseanddeveloper-friendlyfeatures.
1.'(Sayfa Tabanlı Yapı)': Uygulama,sayfatabanlıbiryapıyasahiptir.Hersayfa,projedizinindeki"pages"klasöründebulunanbirdosyayakarşılıkgelir.Busayedeotomatikolarakroute'lar oluşturulur.2. '(Server-SideRendering(SSR))': Next.js, sayfaları sunucu tarafında oluşturarak kullanıcıya daha hızlı ve SEO dostu bir deneyim sunar. Bu, sayfanın içeriğinin sunucu tarafında oluşturulup kullanıcıya gönderilmesi anlamına gelir.3. '(Client-SideRouting)': Sayfalar arası geçişler, tarayıcıda gerçekleşen client-side routing ile sağlanır. Bu, sayfalar arası geçişlerin daha hızlı olmasını sağlar.4. '(APIRoutes)': Uygulamanın sunucu tarafında çalışan basit APIlar oluşturmak için özel bir API rotası mekanizması bulunmaktadır.5. '(ÖnYüklemelerveVeriGetirme)': Sayfa yüklendiğinde veya kullanıcı bir linke tıkladığında otomatik olarak veri çekme işlemlerini yönetmek için özel fonksiyonlar kullanılabilir.6. '(ModülerYapı)': Next.js, modüler bir yapıya sahiptir ve bir dizi ön tanımlı özellik içerir. Bunlar, uygulama geliştirmeyi daha hızlı ve etkili hale getirir.7. '(StaticSiteGeneration(SSG))': Sayfaların derlenip statik dosyalar olarak sunulmasını sağlar, bu da performans ve ölçeklenebilirlik avantajları sağlar.8. '(AutomaticCodeSplitting)': Otomatik kod bölme özelliği sayesinde sadece kullanıcı ihtiyaç duyduğu kod parçaları indirilir, bu da daha hızlı yükleme süreleri sağlar.9. '(CustomizableHeadElement)': Her sayfanın başlık, meta etiketleri gibi başlık elementlerini özelleştirmek için kolay bir yol sunar.10. '(TypeScriptDesteği)': Next.js, JavaScript yanında TypeScripti de destekler, bu da daha güvenli ve daha okunabilir kod yazmayı sağlar.
Next.js, geliştiricilere hızlı bir şekilde ölçeklenebilir ve performanslı web uygulamaları oluşturmak için güçlü bir temel sağlar.
3. What is Routing?
Routingislikegiving'(directions)'toawebsite.Whenyoutypeawebaddress(URL)intoyourbrowser,routingtellsthewebsitewhichpageorthingtoshowyou.It's like a '(mapthatquides)' the website to the right place when you click a link or enter a web address. So, routing helps the website know what to display based on what you'relookingfor.
Basic Routing
https://localhost:3000/about
bu url adresini olusturmak icin about folder'i olusturulur ve icine page.js file'i acilir
not: file ismi page.js olmak zorunda
5. Nested Routing
Nested Routing
https://localhost:3000/users/about
bu url adresini olusturmak icin users folder'i olusturulur ve icine page.js file'i acilir ve icine about folder'i olusturulup icine page.js file acilir
not: file ismi page.js olmak zorunda
6. What is Link?
Link is a component provided by Next.js allows you to create links to navigate between pages in your application.
It's primarily used for declarative, client-side navigation. When you clieck on a link created with Link, it prevents the default browser full-page refresh and fetches the new page content on the client side, resulting in a faster and smoother user experience.
It's typically used in your component's JSX code to create clickable links that lead to other pages within your Next.js application.
Link, Next.js tarafından sağlanan bir bileşendir ve uygulamanızdaki sayfalar arasında gezinmek için bağlantılar oluşturmanıza olanak tanır.
Öncelikle bildirimsel, istemci tarafı gezinme için kullanılır. Link ile oluşturulan bir bağlantıya tıkladığınızda, varsayılan tarayıcı tam sayfa yenilemesini önler ve yeni sayfa içeriğini istemci tarafında getirerek daha hızlı ve sorunsuz bir kullanıcı deneyimi sağlar.
Genellikle bileşeninizin JSX kodunda, Next.js uygulamanızdaki diğer sayfalara yönlendiren tıklanabilir bağlantılar oluşturmak için kullanılır.
7. What is useRouter()?
useRouter is a hook provided by Next.js that allows you to access the router object and its properties within your component.
It provides programmatic control over the router and allows you to navigate to different pages or perform other routing-related actions in response to user interactions or events within your component.
It's useful when you need to handle navigation or acccess route-specific information directly in your component logic.
useRouter, Next.js tarafından sağlanan ve bileşeninizdeki yönlendirici nesnesine ve özelliklerine erişmenizi sağlayan bir kancadır.
Yönlendirici üzerinde programatik kontrol sağlar ve bileşeninizdeki kullanıcı etkileşimlerine veya olaylara yanıt olarak farklı sayfalara gitmenize veya yönlendirmeyle ilgili diğer eylemleri gerçekleştirmenize olanak tanır.
Navigasyonu işlemeniz veya rotaya özgü bilgilere doğrudan bileşen mantığınızda erişmeniz gerektiğinde kullanışlıdır.
8. What is ignoring routes?
Bir route olustururken url adresinde görülmesini istemedigimiz route folder'ini () icine yazariz.
Örnegin: register ve login sayfalarinin bulundugu bir auth folderinin url ismi
https://localhost:3000/register veya https://localhost:3000/login olsun istiyorsak auth folderini (auth) bu sekilde yazmaliyiz.
9. What is Dynamic Routes?
Dynamic routes in Next.js refer to a feature that allows you to create web pages with variable or dynamic parts in the URL.
Instead of defining individual routes for every possible URL, you can create a single route pattern that matches a variety of dynamic values.
This is extremely useful when you have pages that share a common structure but differ based on specific information in the URL.
Next.js'deki dinamik rotalar, URL'de değişken veya dinamik parçalar içeren web sayfaları oluşturmanıza olanak tanıyan bir özelliği ifade eder.
Olası her URL için ayrı ayrı rotalar tanımlamak yerine, çeşitli dinamik değerlerle eşleşen tek bir rota deseni oluşturabilirsiniz.
Bu, ortak bir yapıyı paylaşan ancak URL'deki belirli bilgilere göre farklılık gösteren sayfalarınız olduğunda son derece kullanışlıdır.
https://localhost:3000/users/fatih bu url adresinde fatih kisisini dinamik olarak degistirmek icin yapilmasi gerekenler:
1. app folderinin icine users folderi acilir ve her zaman yapilmasi gereken page.js file'i olusturulur.
2. users folder'inin icine [user] köseli parantez icine user isimli folder acilir ve onun icine page.js file'i olusturulur.
3. page.js icine ise 'use client' yazilir sonrasinda da {params} yardimiyla dynamic routelar olusturulur.
10. Catch-All Routes
In Next.js, the [...foldername] notation indicates that you are using a catch-all route, which allows you to capture multiple URL segments and treat them as a dynamic array of values. This is useful when you want to create dynamic routes that can handle varying numbers of URL segments.
Next.js'de [...foldername] notasyonu, birden fazla URL segmentini yakalamanıza ve bunları dinamik bir değer dizisi olarak ele almanıza olanak tanıyan bir catch-all rotası kullandığınızı gösterir. Bu, değişen sayıda URL segmentini işleyebilen dinamik rotalar oluşturmak istediğinizde kullanışlıdır.
https://localhost:3000/users/fatih/projects/e-commerce/ gibi bir url adresimiz oldugunu varsayalim.
bu url adresinde https://localhost:3000/users adresinden sonrasini yani bu kismi fatih/projects/e-commerce/ dynamic olarak kullanabiliriz.
11. Page Not Found
Next.js te bu sayfayi olusturmak cok basittir. app folder'inin icine not-found.js file'i olusturmamiz yeterlidir. Next.js te zaten bu sayfa default olarak bulunmaktadir
12. Redirect?
Next.js 14 ile birlikte gelen bir özellik, redirect fonksiyonudur. Bu fonksiyon, sayfa içindeki bir bileşen veya yönlendirme işlevi aracılığıyla sayfanın başka bir yerine yönlendirme yapmanıza olanak tanır.
13. What is Server-Component?
React Server Components allow you to write UI that can be rendered and optionally cached on the server. In Next.js, the rendering work is further split by route segments to enable streaming and partial rendering, and there are three different server rendering strategies:
Static Rendering
Dynamic Rendering
Streaming
React Sunucu Bileşenleri, sunucuda render edilebilen ve isteğe bağlı olarak önbelleğe alınabilen kullanıcı arayüzü yazmanıza olanak tanır. Next.js'de render işi, akış ve kısmi render'ı etkinleştirmek için rota segmentleri ile daha da bölünmüştür ve üç farklı sunucu render stratejisi vardır:
Statik Rendering
Dinamik Rendering
Akış
14. What is Client Component?
Client Components allow you to write interactive UI that can be rendered on the client at request time. In Next.js, client rendering is opt-in, meaning you have to explicitly decide what components React should render on the client.
İstemci Bileşenleri, istek anında istemcide işlenebilen etkileşimli kullanıcı arayüzü yazmanıza olanak tanır. Next.js'de istemci oluşturma isteğe bağlıdır, yani React'in istemcide hangi bileşenleri oluşturması gerektiğine açıkça karar vermeniz gerekir.
Server Componentin kullanildigi yerler:
1. Fetch data
2. Access backend resources (directly)
3. Keep sensitive information on the server (access tokens, API keys, etc)
4. Keep large dependencies on the server / Reduce client-side JavaScript
Client Componentin kullanildigi yerler:
1. Add interactivity and event listeners (onClick(), onChange(), etc)
2. Use State and Lifecycle Effects (useState(), useReducer(), useEffect(), etc)
3. Use browser-only APIs
4. Use custom hooks that depend on state, effects, or browser-only APIs
5. Use React Class components
16. What is Layout?
A layout is like a blueprint that helps you make all the pages of your website lok the same. It's a way to put common things, header footer, and other stuff that appears on every page, in one place. This makes it easy to keep a similar look on all your web pages. So, a layout is a handy tool that lets you keep things tidy and consistent on your website.
Düzen, web sitenizin tüm sayfalarının aynı görünmesini sağlamanıza yardımcı olan bir plan gibidir. Ortak şeyleri, üstbilgi altbilgisini ve her sayfada görünen diğer şeyleri tek bir yere koymanın bir yoludur. Bu, tüm web sayfalarınızda benzer bir görünüm elde etmenizi kolaylaştırır. Dolayısıyla düzen, web sitenizde her şeyi düzenli ve tutarlı tutmanızı sağlayan kullanışlı bir araçtır.