内容简介:Programming is the method to innovate something new and amazing. Being a coder, it is important to be aware of every new upcoming technology.The coders who aren’t familiar with these frameworks might get confused in the beginning, these are the perplexed a
Programming is the method to innovate something new and amazing. Being a coder, it is important to be aware of every new upcoming technology. “Nuxt”, “Next”, “Nest” a little confusing, right? They might sound similar but their practical application is different from each other.
The coders who aren’t familiar with these frameworks might get confused in the beginning, these are the perplexed and complex words. I’m going to explain all the concepts of Nuxt
, Next
, and Nest
so stay tuned with me, in this article you may explore the uses and the installation of these frameworks. Surely, this article will help you to know about these frameworks in depth.
Do you ever think why do we actually need a framework? What are the uses of the framework?
- A framework is a platform that provides a foundation on which software developers can create programs. It allows the coder to make robust applications.
- Also, the framework provides diversified support for developing robust applications with pace and ease because it provides a standard way to build and deploy applications.
Before starting with these frameworks, let’s have a short briefing of CSR (client-side rendering) vs SSR (Server-side Rendering).
- By these platforms, it is important to understand that Vue and React are the client-side Rendered (CSR) framework, which makes the page interactable and viewable.
WORKING OF CSR
:outbox_tray: Server sending the response to the browser :outbox_tray:
↓
:inbox_tray: Browser downloads JavaScript :inbox_tray:
↓
:speech_balloon: Browser executes React :speech_balloon:
↓
:globe_with_meridians: The page now viewable and interactable :globe_with_meridians:
- Using these platforms, Server-side Rendered (SSR) use to make the page interactable.
WORKING OF SSR
Server sending ready to be rendered
:woman::computer:↓
The browser renders the page, Now viewable
:inbox_tray:↓
:ok: Browser executes React :ok:
↓
:globe_with_meridians: Page now Interactable :globe_with_meridians:
The first thing that needs to be clear is these three frameworks- Nust
, Next
, and Nest
are different from each other but comes in Javascript Ecosystem.
If you’re a Vue.js programmer, then you probably heard of Nuxt.js. or if you’re not then let starts with Nuxt!
What is Nuxt.js?
Nust.js is a high-level framework that builds on Vue. It is an open-source application framework that is free and based on Vue.js, also Node.js, Webpack, and Babel.js . Nust comes under universal application which uses “meta-framework” as well as develops single page Vue apps.
The main aim to build applications with Nuxt.js that it is more flexible while creating any project because Nuxt helps the developers to create complex, fast, and universal web applications quickly.
What is Vue.js?
It is an open-source Javascript framework, it is faster as well as smoother to build user interfaces and single-page applications. The reason behind this is, Vue had familiar templating syntax and use of components, integrating or migrating the project make it more understanding by the beginners. For this reason, Vue is the best framework for tech startups or beginners to learn and build applications. Also, useful for large-scale applications as performance-wise.
[Important] The current version of Nuxt.js is v2.9.2
Reasons why the developers consider Nuxt for any project:
1. Build universal apps without any trouble.
The plus point of the Nuxt.js is that the developers can create universal applications easily in the Vue. Most of the people are not familiar with universal apps basically the beginners.
So, what is a universal app?
It is the app that describes JavaScript code that can execute both on the client and the server-side. There are many modern Javascript frameworks like Vue, that aim to build Single-page Applications (SPA). And a universal app completely based on SPA.
-
Nuxt makes coding more simple:
It is boring to build long monotonous projects for developers because it needs more time for the configuration on both server-side and client-side. The main aim is to make it simple to share codes between server and client.
Last but not least, Nuxt gives the developer an asyncData method in the components which use to fetch data and render it on the server-side. This is how Nuxt helps the developers to create universal applications.
2. Provide automatic code-splitting
Nuxt generates a static version of your website with a unique webpack configuration. For every page, it automatically creates the program which builds its own JavaScript file.
Also, it helps to speed up the progressing and keep the size of the JavaScript file small relatively to the application size.
3. Easy to write Single file components
There are many Vue projects using Vue.component
, supported by new Vue ({ el: `#container’ })
to target the container element in the body of every page. It is used only to build small projects (single file) where JavaScript is only used to enhance certain views. It has difficulty managing the big file. Use .vue
extension with single-file components, to solve your problem.
The installation process of Nuxt.js
- Syntax to Install Nuxt:
$ npm i nuxt
- Syntax to create a basic application:
$ npx create-nuxt-app <project-name>
According to the latest update, you can directly start with the CLI create-nuxt-app.
Or start it with a simple template:starter:
The basic Nuxt.js project template express: Nuxt.js + Express koa: Nuxt.js + Koa adonuxt: Nuxt.js + AdonisJS micro: Nuxt.js + Micro nuxtent: Nuxt.js + Nuxtent
module for content-heavy sites.
- Example: Syntax for a basic Hello World app in Nuxt.js
<template> <div> <h1>Hello world!</h1> <NLink to="/about"> About Page </NLink> </div> </template>
Advantages of Nuxt.js
- The main advantage of Nuxt.js is, its main scope is UI rendering while removing away the client/server distribution.
- In Nuxt.js you get automatic code-splitting.
- Statically its render your Vue apps and get all of the benefits of a universal app without a server.
- You can easily set up transitions between your routes and write single-file components.
- It provides an auto-updating server for easy development.
- In Nuxt.js you get ES6/ES7 compilation without any other extra work.
After clear our first concept of Nuxt. Let’s move to the next topic Next.js
If you compare all three frameworks, the most popular framework you get is Next.js from the other two. Let see what is so interesting in this framework that it is popular and developer’s favorite.
What is Next.js?
Next.js is a Javascript framework that uses React to build server-side rendering and static web applications. According to every developer, it the best tool to build websites because it has great features and advantages, which make it the first option for creating web applications.
So, do you think, why it is the first choice of the developer for building web applications?
The first thing that makes it different from the other two frameworks is it doesn’t need any configuration of webpack. Even it comes with its configuration, with some basic React and Javascript knowledge, build your way to development.
Some of you all know about React, but for beginner, let’s have a quick introduction to React.
React is a Javascript library for building user interfaces, it is also known as React.js. It can be used as a base in the development of single-page or mobile applications that make it optimal for fetching rapidly changing. React was created by Facebook.
For using React.js it is important to know about the basic components of React.
Components cab be rendered to a particular element in the DOM by using the React DOM library. There are two primary components in React.
- Functional components
These are the component which declared with a function that then returns some JSX.
Syntax:
function Greeting(props) { return <div>Hello, {props.name}!</div>; }
- Class-based components
These are the components declared using ES6 classes and also known as “stateful” components, because their state holds the values throughout the component and can be passed to child components through props.
Syntax:
class ParentComponent extends React.Component { state = { color: 'green' }; render() { return ( <ChildComponent color={this.state.color} /> ); } }
This is all about React let come to our topic Next.js.
Next.js is a framework that is opinionated and provides a structure for the apps. As well as it is an automatic code-splitting.
[Important] The current version of Next.js is Next.js 9
Some reasons to use Next.js to build your project.
Next.js comes with great features that make it useful as well as popular among the developers.
1. Easy to generate website
For beginners or experienced developers, Next.js is the framework easy to use and get started to build a project. It is easy in Next.js to compile and export the application in HTML.
2. Server-side rendering
Next.js performs server-side rendering by default which makes your application optimized for search engines. In this Next.js come with a head component that allows the developers to add or make dynamic Meta-Tags.
By using SSR you get:
- It provides users an initial render of the applications while loading the code in the background.
- Easily eliminate the need for the client to download code in HTML format.
- Also, help to create SEO friendly applications.
3. Routers
When you create any React application by using create-react-app
, you usually need to install a react-router
and create its custom configuration. But with Next.js it is easier because it comes with its own routers with zero configuration. The main feature is that Next.js take care of all its routers you just sit and create your page inside the pages
folder.
The Installation Process of Next.js
- Syntax to install Next.js:
npm install --save next react react-dom
- Syntax to add a script to your package.json:
{ "scripts": { "dev": "next", "build": "next build", "start": "next start" } }
After that, the file-system is the main API. Every .js
file program that gets automatically processed and rendered.
- Example: Syntax for a basic Hello World app in Next.js
Use ./pages/index.js
inside your project
function Home() { return <div>Hello world!</div>; } export default Home;
Then run npm run dev
.
Advantages of using Next.js
- Next.js is easy to deploy anywhere with Node.js support.
- It can be executed with Express or any other Node.js HTTP server.
- Any unnecessary code is not loaded in Next.js.
- Webpack-based dev environment which supports Hot Module Replacement (HMR).
- Fetch data easily.
- Next.js is simple client-side routing (page=based).
- Every component is server-rendered by default in Next.js.
- As well as, automatic code-splitting which use for faster page loads.
Here we complete our two concepts Nust.js and Next.js, let’s move to the last topic Nest.js
The main thing that makes Nest.js differ from both the frameworks is that it is heavily inspired by Angular.
What is Nest.js?
Nest.js is a framework for building efficient, scalable Node.js server-side applications. It is the modern JavaScript, which is built with TypeScript and uses Express.js. The important thing that Nest.js provides that it preserves compatibility with pure JavaScript and the combine elements of OOP (Object-Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
As similar to TypeScript and a reasonable knowledge of JavaScript help the developer to create the best application in Nest.js. The main aim of Nest.js was to solve the architectural problems ofNode.js by providing back-end applications a modular structure for organizing code into separate modules. The plus point to work in Nest.js that it is fully built with TypeScript which is really beneficial for code type checking by which it helps to facilitate the process of development of the application.
[Imprtant] The current version of Nest.js is version5
Recently, the Nest.js framework is increasing popularity due to its incredible features:
Some features of Nest.js
- Nest.js is open-source (MIT license).
- It is easy to use, learn and develop applications.
- It is a powerful command-line interface (CLI) tool that boosts your productivity.
- It has detailed and well-maintained documentation.
- Also, supports specific modules that help you easily integrate with common technologies and concepts such as TypeORM, Mongoose, GraphQL, Logging, Validation, Caching, and Websockets.
- Also, provide active codebase development and maintenance.
- Leverages typescript which means it is a strongly typed language that super-set of JavaScript.
- Easy to unit testing applications.
- The Nest.js is made for Monoliths and Micro-services (entire section in the documentation regarding the Microservice type of a NestJS application, as well as techniques and recipes).
Nest.js provide the developers with an out-of-the-box application structure that allows them to create highly testable, scalable and easily maintainable applications. As well as it makes use of Express which provides compatibility with a wide range of other libraries that the developer easily uses the myriad third-party plugins which are available.
The Installation of Nest.js
- Syntax to install Nest.js
$ npm i @nestjs/cli $ nest new project-name
-
Example: Syntax for basic Hello World app in Nest.js
Remember, after installing Nest.js with the
npm cli
command, and to create a new project withnest new project-name
.
import { NestFactory } from '@nestjs/core'; import { ApplicationModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(ApplicationModule); await app.listen(2000); } bootstrap();
And then to run the app listen on port 2000, you execute the syntax:
$ npm run start
Advantages of using Nest.js
- The main advantage of the Nest.js is that it has a TypeScript-based web framework, that possible to build any strict type application.
- The framework of Nest.js is very annotation-driven which generates everything to make you easy.
- The project that builds in Nest.js is heavily based on Angular.
- As you know Nest.js is a module-based framework, by which it is easy to externalize general-purpose modules and reuse code in multiple projects.
- The important advantage of the Nest.js is that it uses the latest version of TypeScript that helps the developers to code less and gets productive work. And this is the same withAngular.
Just Remember
Nust– This is the framework to create a Vue application that supports universal rendering.
AND
Next-This is to create a React application that also supports universal rendering.
AND
Nest– This for node applications with additional structure and support.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Python编程无师自通
[美] 科里·奥尔索夫(Cory Althoff) / 宋秉金 / 人民邮电出版社 / 2019-1-1 / 59
畅销Python编程类入门书,美国亚马逊Kindle编程类排行榜榜一。 作者从文科毕业,通过自学编程转行为专业程序员,在硅谷工作多年后成功技术创业。本书不仅教读者如何使用Python语言编程,还会介绍其他书中所忽略的、编程初学者应该了解并掌握的其他所有知识点。 本书作者是一名自学成才的程序员,经过一年的自学,掌握了编程技能并在eBay找到了一份软件工程师的工作。本书是作者结合个人经验写......一起来看看 《Python编程无师自通》 这本书的介绍吧!