Apa itu Next.js?
Next.js merupakan sebuah React framework yang dibentuk buat mengatasi kasus client-side rendering yang dimiliki React. Sebuah halaman website yang dibentuk memakai React ‘terasa ringan’ lantaran tampilan website sangat interaktif.
Selain itu, ketika data berubah, React menggunakan efisien akan mengupdate bagian menurut halaman website yang memang perlu diupdate tanpa perlu reload satu halaman penuh.
Untuk menerima itu seluruh, client wajib load seluruh file JavaScript sebelum konten halaman ditampilkan. apabila file JS relatif akbar maka ketika yang diperlukan buat load pertama kali pula sebagai lebih lama.
Masalah lain menurut client-side rendering merupakan SEO, terdapat kemungkinan web crawler berusaha mengindex halaman yang belum terselesaikan dirender sepenuhnya (lantaran ketika load yang lama). Dan menduga web tadi blank.
Kedua kasus diatas bisa diselesaikan menggunakan teknik pre-rendering. Yaitu halaman HTML dan file JavaScript pada generate sebelum dikirim ke client.
Ada dua bentuk pre-rendering yaitu Server Side Rendering (SSR) dan Static Site Generator (SSG).
Server Side Rendering(SSR)
Sesuai namanya proses render terjadi pada server dan bukan pada client, setiap request ke server akan direspon menggunakan sebuah halaman HTML.
Static Site Generator (SSG)
Setiap request ke server akan direspon menggunakan halaman HTML yang telah terselesaikan digenerate dalam ketika proses build. Teknik cache memakai CDN bisa diterapkan buat mempersingkat ketika akses.
Next.js bisa melakukan keduanya.
Features
Selain pre-rendering, Next.js pula mempunyai beberapa fitur buat memudahkan kita pada menciptakan pelaksanaan React:
- Page-based routing system, alamat menurut halaman merupakan nama file menurut halaman tadi
- Code splitting, code JavaScript dipecah sebagai chunk supaya ketika loading halaman sebagai lebih singkat
- Client-side routing, routing pula sanggup dilakukan pada sisi client
- Fast refresh support, seperti menggunakan hot reloading
- Built-In CSS, support CSS Module, SAAS dan CSS-in-JS
- Automatic Image Optimization, tersedia dalam Next.js versi 10 keatas
- API Routes, menciptakan API tanpa library
Kemudian untuk selanjutnya masuk ke index.js.
import Head from 'next/head';
import LayoutHome from '../../Layouts/LayoutHome';
const pesan = () => {
return (
<div>
<Head>
<title>Pesan</title>
</Head>
<LayoutHome/>
<div className="b-check">
<a href="/" className="button bg-green is-size-6-mobile is-size-5-desktop checkout is-justify-content-left">
<i className="fas fa-arrow-left pr-4 white is-size-5"></i>
<div className="white">Pesan</div>
<i className="far fa-address-book is-flex is-flex-grow-5 is-justify-content-end white"></i>
</a>
</div>
<div className="cari px-5 pt-1 is-size-6-mobile is-size-5-desktop">
<div className="control has-icons-left">
<input type="text" className="input" placeholder="Cari Kontak, Penjual & Pesan"/>
<span className="icon is-small is-left">
<i className="fas fa-search"></i>
</span>
</div>
</div>
<div className="columns is-mobile my-5">
<div className="column has-text-centered divi">
<a className="is-size-5-desktop active">Semua</a>
</div>
<div className="column has-text-centered">
<a className="is-size-5-desktop gray">Belum dibaca</a>
</div>
</div>
<div className="my-5 ats-border">
<div className="is-flex is-justify-content-space-between px-5 mt-3 pb-3 bwh-border">
<i className="fas fa-user-circle fa-3x"></i>
<div className="mx-2">
<div className="is-flex is-justify-content-left">
<h3 className="is-flex has-text-weight-bold is-size-7-mobile">wlijoryan</h3>
<h3 className="is-flex is-size-7-mobile">~</h3>
<h3 className="is-flex is-size-7-mobile">wlijoryan</h3>
</div>
<p className="is-size-7-mobile ">SELAMAT ANDA MENDAPATKAN KEUNTUNGAN...</p>
</div>
<p className="is-flex is-flex-grow-2 is-justify-content-end is-size-7-mobile pl-2 pr-3">27-09-2021</p>
<p className="is-flex is-justify-content-end is-size-7-mobile ">10:10</p>
</div>
</div>
<div className="is-flex is-justify-content-space-between px-5 mt-3 pb-3 bwh-border">
<i className="fas fa-user-circle fa-3x"></i>
<div className="mx-2">
<div className="is-flex is-justify-content-left">
<h3 className="is-flex has-text-weight-bold is-size-7-mobile">wlijoryan</h3>
<h3 className="is-flex is-size-7-mobile">~</h3>
<h3 className="is-flex is-size-7-mobile">wlijoryan</h3>
</div>
<p className="is-size-7-mobile ">SELAMAT ANDA MENDAPATKAN KEUNTUNGAN...</p>
</div>
<p className="is-flex is-flex-grow-2 is-justify-content-end is-size-7-mobile pl-2 pr-3">27-09-2021</p>
<p className="is-flex is-justify-content-end is-size-7-mobile ">10:10</p>
</div>
<div className="is-flex is-justify-content-space-between px-5 mt-3 pb-3 bwh-border">
<i className="fas fa-user-circle fa-3x"></i>
<div className="mx-2">
<div className="is-flex is-justify-content-left">
<h3 className="is-flex has-text-weight-bold is-size-7-mobile">wlijoryan</h3>
<h3 className="is-flex is-size-7-mobile">~</h3>
<h3 className="is-flex is-size-7-mobile">wlijoryan</h3>
</div>
<p className="is-size-7-mobile ">SELAMAT ANDA MENDAPATKAN KEUNTUNGAN...</p>
</div>
<p className="is-flex is-flex-grow-2 is-justify-content-end is-size-7-mobile pl-2 pr-3">27-09-2021</p>
<p className="is-flex is-justify-content-end is-size-7-mobile ">10:10</p>
</div>
<div className="is-flex is-justify-content-space-between px-5 mt-3 pb-3 bwh-border">
<i className="fas fa-user-circle fa-3x"></i>
<div className="mx-2">
<div className="is-flex is-justify-content-left">
<h3 className="is-flex has-text-weight-bold is-size-7-mobile">wlijoryan</h3>
<h3 className="is-flex is-size-7-mobile">~</h3>
<h3 className="is-flex is-size-7-mobile">wlijoryan</h3>
</div>
<p className="is-size-7-mobile ">SELAMAT ANDA MENDAPATKAN KEUNTUNGAN...</p>
</div>
<p className="is-flex is-flex-grow-2 is-justify-content-end is-size-7-mobile pl-2 pr-3">27-09-2021</p>
<p className="is-flex is-justify-content-end is-size-7-mobile ">10:10</p>
</div>
<div className="is-flex is-justify-content-space-between px-5 mt-3 pb-3 bwh-border">
<i className="fas fa-user-circle fa-3x"></i>
<div className="mx-2">
<div className="is-flex is-justify-content-left">
<h3 className="is-flex has-text-weight-bold is-size-7-mobile">wlijoryan</h3>
<h3 className="is-flex is-size-7-mobile">~</h3>
<h3 className="is-flex is-size-7-mobile">wlijoryan</h3>
</div>
<p className="is-size-7-mobile ">SELAMAT ANDA MENDAPATKAN KEUNTUNGAN...</p>
</div>
<p className="is-flex is-flex-grow-2 is-justify-content-end is-size-7-mobile pl-2 pr-3">27-09-2021</p>
<p className="is-flex is-justify-content-end is-size-7-mobile ">10:10</p>
</div>
<div className="has-text-right p-5">
<a className="button bg-green white add-message pl-5 pr-5" href="#"><i className="far fa-envelope fa-2x"></i></a>
</div>
</div>
);
}
export default pesan;
Lalu tambahkan code css dibawah ke dalam folder global.css, jika menggunakan nextjs
@import 'bulma/css/bulma.css';
.swiper {
width: 800px;
height: 350px;
}
p.gg{
text-align: center;
}
input.tb{
width: 40px;
}
.card-content{
padding-top: 0px;
}
a.lihat{
width: 100%;
}
.menu {
position: sticky;
vertical-align: top;
overflow-y: auto;
height: 100vh;
width: 350px;
top: 0;
bottom: 0;
padding-left: 20px;
padding-top: 20px;
background-color: rgb(243, 243, 243);
}
.content {
width: 100%;
}
.border-p{
border-bottom: 1px solid black;
padding:10px 0px;
width: 100%;
text-align: left;
}
.border-px{
border-top: 1px solid black;
border-bottom: 1px solid black;
padding:10px 0px;
width: 100%;
text-align: left;
}
a.bg-gray-bb:hover{
color: gray;
}
.bg-white-nb{
border: none;
background-color: white;
color: green;
}
.bg-white-nb:hover{
border: none;
background-color: white;
color: green;
}
button.jm{
background-color: white;
color: green;
border-color: green;
}
button.wp{
background-color: green;
border: none;
}
.border-r {
border-right: 2px solid rgb(255, 255, 255);
}
div.kk{
width: 90%;
}
div.ml{
width: 50%;
}
figure.is-rounded{
border-radius: 100px;
}
div.is-rounded{
border-radius: 100px;
}
.bg-white{
background-color : rgb(255, 255, 255);
}
.bg-green{
background-color : green;
}
.bg-red {
background-color: rgb(255, 70, 70);
}
.bg-gray {
background-color: rgb(207, 207, 207);
}
.red{
color: red;
}
.white , .table thead td.white{
color : white;
}
.gray{
color : gray;
}
.green {
color : green;
}
.black{
color: black;
}
a.checkout{
width: 100%;
border: none;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
div.b-check{
padding:10px 0px;
}
div.alamat-pengiriman{
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.bg-green-nb{
border: none;
color: white;
background-color: transparent;
}
.bg-green-nb:hover{
border: none;
color: white;
background-color: green;
}
.bg-wite-nb{
border: none;
}
.navbar-item {
font-size: medium;
}
.navbar-link{
color: green;
font-size: medium;
}
.navbar-end .navbar-item:hover {
color: white;
background-color : green;
border-radius: 20px;
}
.navigasi {
padding:10px 20px;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.bg-green {
background-color: green;
}
div.body{
background-image: url("../public/bg.jpg");
background-position: center;
background-size: cover;
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
body{
position: absolute;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#login-form-container{
position: absolute;
width: 100%;
height: 100%;
padding-left: 30px;
padding-right: 30px;
display: flex;
align-items: center;
justify-content: end;
}
div.login{
width: 600px;
background-color: rgba(255, 255, 255, 0.753);
border-radius: 10px;
}
a.tl{
color: green;
}
a.green-nb{
border: none;
color: green;
}
a.green-nb:hover{
background-color: green;
color: white;
}
button.green-gb{
border: solid 1px green;
color: green;
}
a.green-gb{
border: solid 1px green;
color: green;
}
.navbar-brand .navbar-item img {
max-height: 50px;
}
.navbar-menu {
box-shadow: none;
}
.divi {
border-right: 2px solid gray;
}
.active {
color: green;
}
div.aksi .button:hover {
color: white;
}
.btm-border {
border-bottom: 2px solid green;
}
.tp-border {
border-top: 2px solid green;
}
.btm-bordergray {
border-bottom: 2px solid gray;
}
.tp-bordergray {
border-top: 2px solid gray;
}
.masukan {
max-width: 500px
}
.w1000 {
max-width: 1000px;
}
.hscroll {
overflow-x: auto;
padding : 10px;
margin: 10px;
}
.s {
width: 1000px;
}
table thead tr{
background-color: green;
}
.table tr td {
border: none;
}
tr:nth-child(even){background-color: #d4d4d4;}
div.columns {
margin: 0;
}
.wrapper-kasir {
max-width: 400px;
}
.none{
display: none;
}
.w {
word-wrap: break-word;
}
.line-trought{
text-decoration: line-through
}
.diskon{
background-color: red;
border-radius: 15px;
margin-left: 12px;
color: white;
}
.add-message{
width: 60px;
height: 60px;
border:"none";
border-radius: 100px;
}
.underline{
border-bottom: 2px solid green;
}
.shadow{
box-shadow: 2px 0 2px 0 rgb(211, 210, 210);
}
.box-voucher{
width: 100%;
border: none;
background-color: rgb(172, 167, 167);
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.box-ongkir{
width: 90px;
height: 95px;
}
.border-grind{
border: 1px solid green;
}
.blog-img{
width: 90px;
height: 388px;
border-radius: 95px;
}
.shadow{
box-shadow: 4px 4px 2px 4px rgb(163, 162, 162);
border-radius: 8px;
}
Output
Komentar
Posting Komentar