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 voucher = () => {
return (
<div>
<Head>
<title>Voucher Saya</title>
</Head>
<LayoutHome/>
<div className="b-check">
<a href="/" className="button green is-size-6-mobile is-size-5-desktop checkout is-justify-content-left">
<i className="fas fa-arrow-left pr-4 is-size-5"></i>
<div className="black">Voucher Saya</div>
<p className="is-flex is-flex-grow-5 is-justify-content-end is-7 is-offset-7 is-size-6 green">Riwayat</p>
</a>
</div>
<div className="columns border-px pt-0 is-mobile ">
<div className="column has-text-centered">
<a className="is-size-5-desktop underline active">Semua</a>
</div>
<div className="column has-text-centered">
<a className="is-size-5-desktop green">Toko</a>
</div>
</div>
<div className="columns is-mobile">
<div className="column has-text-centered">
<a className="button bg-green white pl-5 pr-5" href="#">Terbaru</a>
</div>
<div className="column has-text-centered">
<a className="button bg-gray pl-5 pr-5" href="#">Segera Berakhir</a>
</div>
</div>
<div className="box-voucher">
<div className="pl-5 pr-5 pt-5 pb-5">
<div className="box is-flex is-align-items-center bg-white">
<div className="column has-text-centered divi">
<i className="far fa-credit-card green pr-5"></i>
<a className="is-size-5-desktop is-size-7-mobile active">Masukkan Kode Voucher</a>
</div>
<div className="column has-text-centered">
<i className="fas fa-film green pr-5"></i>
<a className="is-size-5-desktop is-size-7-mobile black">Dapatkan Voucher Lainnya</a>
</div>
</div>
</div>
<div className="pl-5 pr-5 pt-1 pb-3">
<div className="box is-flex bg-white is-justify-content-space-between">
<div className="is-flex">
<div className="box-ongkir bg-green white is-flex is-flex-grow is-align-items-center has-text-centered">
GRATIS ONGKIR
</div>
<div className="pl-5">
<div>
<a className="is-size-5-desktop black has-text-weight-bold">Voucher Gratis Ongkir</a>
</div>
<div className="pt-5">
<a className="is-size-7-desktop is-size-7-mobile green">Berakhir dlm: 3 jam</a>
</div>
</div></div>
<div className="">
<div className="is-flex is-align-items-center">
<p className="is-size-7-mobile is-size-7-dekstop has-text-right green ">Pakai</p>
<i className="fas fa-chevron-right pl-2"></i>
</div>
<div className="pt-5">
<p className="is-size-7-mobile is-size-7-dekstop green has-text-right">S&K</p>
</div>
</div>
</div>
</div>
<div className="pl-5 pr-5 pt-1 pb-3">
<div className="box is-flex bg-white is-justify-content-space-between">
<div className="is-flex">
<div className="box-ongkir bg-green white is-flex is-flex-grow is-align-items-center has-text-centered">
GRATIS ONGKIR
</div>
<div className="pl-5">
<div>
<a className="is-size-5-desktop black has-text-weight-bold">Voucher Gratis Ongkir</a>
</div>
<div className="pt-5">
<a className="is-size-7-desktop is-size-7-mobile green">Berakhir dlm: 3 jam</a>
</div>
</div></div>
<div className="">
<div className="is-flex is-align-items-center">
<p className="is-size-7-mobile is-size-7-dekstop has-text-right green ">Pakai</p>
<i className="fas fa-chevron-right pl-2"></i>
</div>
<div className="pt-5">
<p className="is-size-7-mobile is-size-7-dekstop green has-text-right">S&K</p>
</div>
</div>
</div>
</div>
<div className="pl-5 pr-5 pt-1 pb-3">
<div className="box is-flex bg-white is-justify-content-space-between">
<div className="is-flex">
<div className="box-ongkir bg-green white is-flex is-flex-grow is-align-items-center has-text-centered">
GRATIS ONGKIR
</div>
<div className="pl-5">
<div>
<a className="is-size-5-desktop black has-text-weight-bold">Voucher Gratis Ongkir</a>
</div>
<div className="pt-5">
<a className="is-size-7-desktop is-size-7-mobile green">Berakhir dlm: 3 jam</a>
</div>
</div></div>
<div className="">
<div className="is-flex is-align-items-center">
<p className="is-size-7-mobile is-size-7-dekstop has-text-right green ">Pakai</p>
<i className="fas fa-chevron-right pl-2"></i>
</div>
<div className="pt-5">
<p className="is-size-7-mobile is-size-7-dekstop green has-text-right">S&K</p>
</div>
</div>
</div>
</div>
<div className="pl-5 pr-5 pt-1 pb-3">
<div className="box is-flex bg-white is-justify-content-space-between">
<div className="is-flex">
<div className="box-ongkir bg-green white is-flex is-flex-grow is-align-items-center has-text-centered">
GRATIS ONGKIR
</div>
<div className="pl-5">
<div>
<a className="is-size-5-desktop black has-text-weight-bold">Voucher Gratis Ongkir</a>
</div>
<div className="is flex pt-3">
<div className="is-flex">
<div className="pr-4">
<p className="is-size-7-mobile is-size-7-dekstop green border-grind">COD</p></div>
<div>
<p className="is-size-7-mobile is-size-7-dekstop green border-grind">WlijoPay</p></div></div>
</div>
<div className="">
<a className="is-size-7-desktop is-size-7-mobile gray">Hingga 31.11.2021</a>
</div>
</div></div>
<div className="">
<div className="is-flex is-align-items-center">
<p className="is-size-7-mobile is-size-7-dekstop has-text-right green ">Pakai</p>
<i className="fas fa-chevron-right pl-2"></i>
</div>
<div className="pt-5">
<p className="is-size-7-mobile is-size-7-dekstop green has-text-right">S&K</p>
</div>
</div>
</div>
</div>
<p className="is-size-7-mobile is-size-7-dekstop gray pb-3 has-text-centered">Lihat Lainnya</p>
</div>
</div>
);
}
export default voucher;
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