{"id":3068,"date":"2023-02-20T17:22:42","date_gmt":"2023-02-20T10:22:42","guid":{"rendered":"https:\/\/www.marketenterprise.vn\/blog\/?p=3068"},"modified":"2023-04-03T14:07:59","modified_gmt":"2023-04-03T07:07:59","slug":"build-blog-don-gian-nextjs-phan-3","status":"publish","type":"post","link":"https:\/\/www.marketenterprise.vn\/blog\/build-blog-don-gian-nextjs-phan-3.html","title":{"rendered":"BUILD BLOG \u0110\u01a0N GI\u1ea2N &#8211; NextJS Ph\u1ea7n 3"},"content":{"rendered":"<h2>Tri\u1ec3n khai Blog \u0111\u01a1n gi\u1ea3n<\/h2>\n<p><span style=\"font-weight: 400;\">\u0110\u1ea7u ti\u00ean m\u00ecnh xin gi\u1edbi thi\u1ec7u \u0111\u1ebfn c\u00e1c b\u1ea1n techtask m\u00e0 m\u00ecnh th\u01b0\u1eddng d\u00f9ng trong d\u1ef1 \u00e1n Nextjs: <\/span><b>Next.Js + Tailwind CSS + TypeScript + ESlint<\/b><span style=\"font-weight: 400;\">. T\u00f9y v\u00e0o d\u1ef1 \u00e1n m\u1ed7i team th\u00ec c\u00e1c b\u1ea1n ch\u1ecdn c\u00f4ng ngh\u1ec7 ph\u00f9 h\u1ee3p nh\u00e9.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">B\u00e2y gi\u1edd m\u00ecnh s\u1ebd b\u1eaft \u0111\u1ea7u setup project Next JS:<\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ea1o project Next JS b\u1eb1ng l\u1ec7nh: <\/span><i><span style=\"font-weight: 400;\">yarn create next-app &#8211;typescript blog-nextjs<\/span><\/i><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Sau khi t\u1ea3i xong project b\u1ea1n d\u00f9ng l\u1ec7nh: <\/span><i><span style=\"font-weight: 400;\">cd\u00a0 blog-nextjs<\/span><\/i><span style=\"font-weight: 400;\"> \u0111\u1ec3 v\u00e0o th\u01b0 m\u1ee5c project v\u00e0o run l\u1ec7nh start project: <\/span><i><span style=\"font-weight: 400;\">yarn dev<\/span><\/i><\/p>\n<figure id=\"attachment_3069\" aria-describedby=\"caption-attachment-3069\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175116\/hinh1-1-300x166.png\" alt=\"Setup project Next JS\" width=\"300\" height=\"166\" class=\"size-medium wp-image-3069\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175116\/hinh1-1-300x166.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175116\/hinh1-1-1024x568.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175116\/hinh1-1-768x426.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175116\/hinh1-1-1536x852.png 1536w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175116\/hinh1-1-1568x870.png 1568w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175116\/hinh1-1.png 1676w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3069\" class=\"wp-caption-text\">Setup project Next JS<\/figcaption><\/figure>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">V\u1eady l\u00e0 ch\u00fang ta \u0111\u00e3 ch\u1ea1y \u0111\u01b0\u1ee3c project, ti\u1ebfp theo ch\u00fang ta s\u1ebd install Tailwind CSS v\u00e0o project b\u1eb1ng 2 c\u00e2u l\u1ec7nh sau:<\/span><\/li>\n<\/ul>\n<p><em><span style=\"font-weight: 400;\">npm install -D tailwindcss postcss autoprefixer<\/span><\/em><\/p>\n<p><em><span style=\"font-weight: 400;\">npx tailwindcss init -p<\/span><\/em><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ch\u00fang ta s\u1ebd config cho c\u00e1c template s\u1eed d\u1ee5ng tailwindCSS nh\u01b0 sau nh\u00e9:<\/span><\/li>\n<\/ul>\n<figure id=\"attachment_3070\" aria-describedby=\"caption-attachment-3070\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175121\/hinh2-300x170.png\" alt=\"TailwindCSS\" width=\"300\" height=\"170\" class=\"size-medium wp-image-3070\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175121\/hinh2-300x170.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175121\/hinh2-1024x580.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175121\/hinh2-768x435.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175121\/hinh2.png 1076w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3070\" class=\"wp-caption-text\">TailwindCSS<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_3071\" aria-describedby=\"caption-attachment-3071\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175124\/hinh3-300x193.png\" alt=\"TailwindCSS 2\" width=\"300\" height=\"193\" class=\"size-medium wp-image-3071\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175124\/hinh3-300x193.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175124\/hinh3-1024x657.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175124\/hinh3-768x493.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175124\/hinh3.png 1041w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3071\" class=\"wp-caption-text\">TailwindCSS 2<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">B\u1ea1n t\u1eaft app v\u00e0 ch\u1ea1y l\u1ea1i l\u1ec7nh: yarn dev \u0111\u1ec3 build l\u1ea1i nh\u00e9. Sau \u0111\u00f3 th\u00eam v\u00e0o 1 class m\u00e0u background c\u1ee7a Tailwind CSS \u201cbg-gray-200\u201d \u0111\u1ec3 test xem \u0111\u00e3 effect ch\u01b0a nh\u00e9.<\/span><\/li>\n<\/ul>\n<figure id=\"attachment_3072\" aria-describedby=\"caption-attachment-3072\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175127\/hinh4-300x163.png\" alt=\"Tailwind CSS \u201cbg-gray-200\u201d\" width=\"300\" height=\"163\" class=\"size-medium wp-image-3072\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175127\/hinh4-300x163.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175127\/hinh4-1024x555.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175127\/hinh4-768x416.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175127\/hinh4.png 1383w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3072\" class=\"wp-caption-text\">Tailwind CSS \u201cbg-gray-200\u201d<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">V\u00e0 k\u1ebft qu\u1ea3 l\u00e0 background \u0111\u00e3 \u0111\u1ed5i m\u00e0u gray c\u1ee7a Tailwind CSS th\u00e0nh c\u00f4ng.<\/span><\/li>\n<\/ul>\n<figure id=\"attachment_3073\" aria-describedby=\"caption-attachment-3073\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175130\/hinh5-1-300x152.png\" alt=\"Tailwind CSS th\u00e0nh c\u00f4ng\" width=\"300\" height=\"152\" class=\"size-medium wp-image-3073\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175130\/hinh5-1-300x152.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175130\/hinh5-1-1024x517.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175130\/hinh5-1-768x388.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175130\/hinh5-1-1536x776.png 1536w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175130\/hinh5-1-1568x792.png 1568w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175130\/hinh5-1.png 1829w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3073\" class=\"wp-caption-text\">Tailwind CSS th\u00e0nh c\u00f4ng<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h3><span style=\"font-weight: 400;\">M\u00ecnh s\u1ebd gi\u1ea3i th\u00edch c\u00e1c th\u01b0 m\u1ee5c c\u1ee7a project NextJS<\/span><\/h3>\n<figure id=\"attachment_3074\" aria-describedby=\"caption-attachment-3074\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175134\/hinh6-1-300x259.png\" alt=\"C\u00e1c th\u01b0 m\u1ee5c c\u1ee7a project NextJS\" width=\"300\" height=\"259\" class=\"size-medium wp-image-3074\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175134\/hinh6-1-300x259.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175134\/hinh6-1-1024x886.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175134\/hinh6-1-768x664.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175134\/hinh6-1.png 1081w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3074\" class=\"wp-caption-text\">C\u00e1c th\u01b0 m\u1ee5c c\u1ee7a project NextJS<\/figcaption><\/figure>\n<ul>\n<li><b>Components<\/b><b>: <\/b><span style=\"font-weight: 400;\">Th\u01b0 m\u1ee5c ch\u1ee9a c\u00e1c component c\u1ea7n thi\u1ebft cho project (t\u1ef1 t\u1ea1o)<\/span><\/li>\n<li><b>Public<\/b><span style=\"font-weight: 400;\">: Th\u01b0 m\u1ee5c ch\u1ee9a c\u00e1c t\u00e0i nguy\u00ean nh\u01b0 h\u00ecnh \u1ea3nh, files data,..<\/span><\/li>\n<li><b>Styles:<\/b><span style=\"font-weight: 400;\"> Th\u01b0 m\u1ee5c ch\u1ee9a c\u00e1c files css<\/span><\/li>\n<li><b><\/b><b>Pages: <\/b><span style=\"font-weight: 400;\">Ch\u1ee9a c\u00e1c page c\u1ee7a trang web, t\u00ean folder trong th\u01b0 m\u1ee5c pages s\u1ebd l\u00e0 route cho c\u00e1c page (VD: trong pages c\u1ee7a m\u00ecnh c\u00f3 th\u01b0 m\u1ee5c post v\u1eady th\u00ec m\u00ecnh s\u1ebd c\u00f3 link v\u00e0o c\u00e1c b\u00e0i post nh\u01b0 sau: <\/span><i><span style=\"font-weight: 400;\">localhost:3001\/post\/1<\/span><\/i><span style=\"font-weight: 400;\">\u00a0 \u201c1\u201d l\u00e0 s\u1ed1 id c\u1ee7a b\u1ea5t k\u1ef3 b\u00e0i post n\u00e0o.) V\u00e0 trong th\u01b0 m\u1ee5c pages c\u0169ng c\u00f3 s\u1eb5n th\u01b0 m\u1ee5c api: \u0111\u00e2y l\u00e0 ph\u1ea7n \u0111\u1ec3 vi\u1ebft API x\u1eed l\u00fd backend cho h\u1ec7 th\u1ed1ng.<\/span><\/li>\n<\/ul>\n<h3>B\u00e2y gi\u1edd ch\u00fang ta b\u1eaft \u0111\u1ea7u x\u00e2y giao di\u1ec7n cho blog \u0111\u01a1n gi\u1ea3n nh\u00e9:<\/h3>\n<h4>Public\/data\/posts.json<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">[\r\n {\r\n   \"id\": 1,\r\n   \"title\": \"10 Extensions VS Code ng\u01b0\u1eddi m\u1edbi h\u1ecdc HTML&amp;CSS c\u1ea7n ph\u1ea3i bi\u1ebft\",\r\n   \"content\": \"\u0110i\u1ec1u ch\u00ednh y\u1ebfu c\u1ee7a vi\u1ec7c h\u1ecdc l\u1eadp tr\u00ecnh \u0111\u00f3 ch\u00ednh l\u00e0 ki\u1ebfn th\u1ee9c v\u1ec1 c\u00e1c ng\u00f4n ng\u1eef, c\u00e1c c\u00f4ng ngh\u1ec7 m\u1edbi c\u00f3 trong m\u1ea3ng l\u1eadp tr\u00ecnh \u0111\u00f3.\\n\\nTuy nhi\u00ean sau nh\u1eefng kho\u1ea3ng th\u1eddi gian t\u00ecm hi\u1ec3u v\u1ec1 syntax, nh\u1eefng kh\u00e1i ni\u1ec7m l\u1eadp tr\u00ecnh n\u1eb7ng \u0111\u00f4, nh\u1eefng b\u00e0i thu\u1eadt to\u00e1n \\\"n\u1ed5 n\u00e3o\\\" th\u00ec b\u1ea1n c\u0169ng c\u00f3 th\u1ec3 cho ph\u00e9p b\u1ea3n th\u00e2n m\u00ecnh gi\u1ea3i lao m\u1ed9t ch\u00fat v\u1edbi nh\u1eefng th\u1ee9 nh\u1eb9 nh\u00e0ng h\u01a1n nh\u00e9!\\n\\n\u0110i\u1ec1u n\u00e0y kh\u00f4ng ch\u1ec9 gi\u00fap vi\u1ec7c h\u1ecdc tr\u1edf n\u00ean d\u1ec5 th\u1edf h\u01a1n m\u00e0 n\u00f3 c\u00f2n gi\u00fap qu\u00e1 tr\u00ecnh chinh ph\u1ee5c ki\u1ebfn th\u1ee9c c\u1ee7a b\u1ea1n tr\u1edf n\u00ean th\u00fa v\u1ecb h\u01a1n r\u1ea5t nhi\u1ec1u!\\n\\nNh\u01b0 vi\u1ec7c t\u00ecm hi\u1ec3u nh\u1eefng extension trong VS Code ch\u1eb3ng h\u1ea1n. N\u00f3 kh\u00f4ng gi\u00fap b\u1ea1n ki\u1ebfm ti\u1ec1n ngay, n\u00f3 c\u0169ng kh\u00f4ng ph\u1ea3i th\u1ee9 quan tr\u1ecdng nh\u1ea5t b\u1ea1n c\u1ea7n h\u1ecdc nh\u01b0ng n\u00f3 s\u1ebd gi\u00fap b\u1ea1n l\u00e0m vi\u1ec7c nhanh h\u01a1n v\u00e0 c\u00f3 c\u1ea3m h\u1ee9ng h\u01a1n khi code.\",\r\n   \"image\": \"post1.png\",\r\n   \"author\": \"tuongho\",\r\n   \"created_at\": \"2023-01-03T17:00:00.000Z\"\r\n },\r\n {\r\n   \"id\": 2,\r\n   \"title\": \"Top 10 k\u00eanh youtube b\u1ed5 \u00edch v\u1ec1 ReactJS v\u00e0 ph\u00e1t tri\u1ec3n web\",\r\n   \"content\": \"ReactJS l\u00e0 m\u1ed9t trong nh\u1eefng framework l\u1eadp tr\u00ecnh \u0111\u01b0\u1ee3c c\u00e1c nh\u00e0 ph\u00e1t tri\u1ec3n quan t\u00e2m v\u00e0 y\u00eau th\u00edch. Hi\u1ec7n nay, c\u00f3 r\u1ea5t nhi\u1ec1u k\u00eanh Youtube v\u1ec1 ReactJS v\u00e0 c\u00e1c ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh, \u1edf \u0111\u00f3 b\u1ea1n c\u00f3 th\u1ec3 h\u1ecdc, tr\u1ea3i nghi\u1ec7m th\u1ef1c t\u1ebf v\u00e0 ph\u00e2n t\u00edch chuy\u00ean s\u00e2u.\\n\\n\u0110i\u1ec1u \u0111\u1eb7c bi\u1ec7t l\u00e0 ch\u00fang ho\u00e0n to\u00e0n mi\u1ec5n ph\u00ed, b\u1ea1n c\u00f3 th\u1ec3 h\u1ecdc b\u1ea5t c\u1ee9 khi n\u00e0o c\u00f3 th\u1eddi gian. Trong b\u00e0i vi\u1ebft n\u00e0y, 200Lab s\u1ebd gi\u1edbi thi\u1ec7u \u0111\u1ebfn b\u1ea1n top 10 k\u00eanh Youtube v\u1ec1 ReactJS v\u00e0 ph\u00e1t tri\u1ec3n web b\u1ed5 \u00edch m\u00e0 b\u1ea1n n\u00ean bi\u1ebft n\u1ebfu b\u1ea1n \u0111ang quan t\u00e2m \u0111\u1ebfn framework ReactJS.\",\r\n   \"image\": \"post2.png\",\r\n   \"author\": \"tuongho\",\r\n   \"created_at\": \"2022-12-30T17:00:00.000Z\"\r\n },\r\n {\r\n   \"id\": 3,\r\n   \"title\": \"T\u1ea1i sao n\u00ean s\u1eed d\u1ee5ng ReactJS \u0111\u1ec3 ph\u00e1t tri\u1ec3n website?\",\r\n   \"content\": \"Khi nh\u00ecn v\u00e0o m\u1ed9t website, b\u1ea1n th\u1ea5y \u0111i\u1ec1u g\u00ec thu h\u00fat b\u1ea1n nh\u1ea5t? Ph\u00f4ng ch\u1eef c\u1ee7a website, giao di\u1ec7n ng\u01b0\u1eddi d\u00f9ng hay nh\u1eefng thi\u1ebft k\u1ebf? H\u1ea7u h\u1ebft ng\u01b0\u1eddi d\u00f9ng th\u00edch m\u1ed9t website c\u00f3 giao di\u1ec7n ng\u01b0\u1eddi d\u00f9ng th\u00e2n thi\u1ec7n v\u00e0 d\u1ec5 s\u1eed d\u1ee5ng, \u0111\u00f3 l\u00e0 n\u01a1i React xu\u1ea5t hi\u1ec7n.\\n\\nReactJS \u0111\u00e3 n\u1ed5i l\u00ean nh\u01b0 m\u1ed9t trong nh\u1eefng th\u01b0 vi\u1ec7n l\u1edbn nh\u1ea5t \u0111\u01b0\u1ee3c c\u00e1c nh\u00e0 ph\u00e1t tri\u1ec3n v\u00e0 doanh nghi\u1ec7p s\u1eed d\u1ee5ng trong v\u00e0i n\u0103m qua. Trong b\u00e0i vi\u1ebft n\u00e0y, ch\u00fang ta s\u1ebd c\u00f9ng t\u00ecm hi\u1ec3u v\u1ec1 nh\u1eefng l\u00fd do v\u00ec sao ReactJS \u0111\u01b0\u1ee3c xem l\u00e0 ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh m\u00e0 c\u00e1c developer n\u00ean l\u1ef1a ch\u1ecdn trong t\u01b0\u01a1ng lai.\",\r\n   \"image\": \"post3.png\",\r\n   \"author\": \"tuongho\",\r\n   \"created_at\": \"2022-12-31T17:00:00.000Z\"\r\n },\r\n {\r\n   \"id\": 4,\r\n   \"title\": \"ReactJS vs React Native - G\u00e0 c\u00f9ng m\u1ed9t m\u1eb9 li\u1ec7u c\u00f3 gi\u1ed1ng nhau?\",\r\n   \"content\": \"B\u1ea1n c\u00f3 \u0111ang r\u1ed1i gi\u1eefa ReactJS vs React Native? N\u00ean ch\u1ecdn c\u00e1i n\u00e0o th\u00ec t\u1ed1t h\u01a1n? C\u00f3 th\u1ec3 t\u00e1i s\u1eed d\u1ee5ng code c\u1ee7a ReactJS cho React Native hay kh\u00f4ng? H\u00e3y kh\u00e1m ph\u00e1 c\u00e2u tr\u1ea3 l\u1eddi th\u00f4ng qua b\u00e0i vi\u1ebft so s\u00e1nh ReactJS vs React Native n\u00e0y b\u1ea1n nh\u00e9!\\n\\nTr\u01b0\u1edbc khi \u0111i v\u00e0o so s\u00e1nh chi ti\u1ebft ReactJS vs React Native, h\u00e3y c\u00f9ng t\u00ecm hi\u1ec3u s\u01a1 qua l\u1ecbch s\u1eed c\u1ee7a hai c\u00f4ng ngh\u1ec7 m\u1ea1nh m\u1ebd n\u00e0y.\\n\\nReactJS v\u00e0 React Native c\u00f3 m\u1ed9t l\u1ecbch s\u1eed kh\u00e1 l\u00e0 th\u00fa v\u1ecb\",\r\n   \"image\": \"post4.png\",\r\n   \"author\": \"tuongho\",\r\n   \"created_at\": \"2023-01-01T17:00:00.000Z\"\r\n },\r\n {\r\n   \"id\": 5,\r\n   \"title\": \"Docker l\u00e0 g\u00ec? Khi n\u00e0o n\u00ean d\u00f9ng Docker?\",\r\n   \"content\": \"Docker l\u00e0 m\u1ed9t trong nh\u1eefng requirement xu\u1ea5t hi\u1ec7n li\u00ean t\u1ee5c trong nh\u1eefng JD tuy\u1ec3n d\u1ee5ng backend developer trong nh\u1eefng n\u0103m g\u1ea7n \u0111\u00e2y. R\u1ed3i n\u00e0o l\u00e0 DevOps, r\u1ed3i SRE, CI\/CD \u0111\u1ec1u c\u1ea7n ph\u1ea3i bi\u1ebft Docker. Qua b\u00e0i vi\u1ebft n\u00e0y m\u00ecnh hy v\u1ecdng s\u1ebd gi\u00fap c\u00e1c b\u1ea1n hi\u1ec3u \u0111\u01b0\u1ee3c m\u1ed9t ch\u00fat v\u1ec1 Docker v\u00e0 l\u00fd do t\u1ea1i sao l\u1ea1i c\u1ea7n n\u00f3 nh\u01b0 th\u1ebf.\",\r\n   \"image\": \"post5.png\",\r\n   \"author\": \"tuongho\",\r\n   \"created_at\": \"2023-01-02T17:00:00.000Z\"\r\n }\r\n]\r\n\r\n\r\n<\/pre>\n<h4>Layouts\/Main: ch\u1ec9 thay \u0111\u1ed5i n\u1ed9i dung b\u00e0i post, c\u00f2n l\u1ea1i layout s\u1ebd gi\u1eef nguy\u00ean header, footer.<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">import type { ReactNode } from 'react';\r\nimport { Header } from '..\/components\/Header';\r\nimport { Footer } from '..\/components\/Footer';\r\n\r\n\r\ntype IMainProps = {\r\n children: ReactNode;\r\n};\r\n\r\n\r\nconst Main = (props: IMainProps) =&gt; (\r\n &lt;&gt;\r\n   &lt;main className=\"bg-slate-900 min-h-screen\"&gt;\r\n     &lt;div className=\"container lg:px-56 px-4\"&gt;\r\n       &lt;Header blogName={'Blog NextJS'} \/&gt;\r\n       &lt;&gt;{props.children}&lt;\/&gt;\r\n       &lt;Footer \/&gt;\r\n     &lt;\/div&gt;\r\n   &lt;\/main&gt;\r\n &lt;\/&gt;\r\n);\r\n\r\n\r\nexport { Main };\r\n<\/pre>\n<h4>Components\/Header<\/h4>\n<figure id=\"attachment_3075\" aria-describedby=\"caption-attachment-3075\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175138\/hinh7-1-300x170.png\" alt=\"Components\/Header\" width=\"300\" height=\"170\" class=\"size-medium wp-image-3075\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175138\/hinh7-1-300x170.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175138\/hinh7-1-1024x580.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175138\/hinh7-1-768x435.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175138\/hinh7-1.png 1391w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3075\" class=\"wp-caption-text\">Components\/Header<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h4>Component\/Footer<\/h4>\n<figure id=\"attachment_3076\" aria-describedby=\"caption-attachment-3076\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175142\/hinh8-1-300x192.png\" alt=\"Component\/Footer\" width=\"300\" height=\"192\" class=\"size-medium wp-image-3076\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175142\/hinh8-1-300x192.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175142\/hinh8-1-1024x655.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175142\/hinh8-1-768x491.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175142\/hinh8-1.png 1451w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3076\" class=\"wp-caption-text\">Component\/Footer<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">V\u00e0 \u0111\u00e2y s\u1ebd l\u00e0 trang index ch\u00ednh c\u1ee7a ch\u00fang ta v\u1edbi danh s\u00e1ch c\u00e1c b\u00e0i post:<\/span><b> pages\/index. <\/b><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng k\u1ebft h\u1ee3p layout Main. \u1edf Index b\u1ea1n c\u00f3 th\u1ec3 c\u1ea5u h\u00ecnh th\u1ebb Head c\u1ee7a website theo c\u00e1ch c\u1ee7a m\u00ecnh \u0111\u1ec3 t\u0103ng hi\u1ec7u qu\u1ea3 SEO nh\u00e9.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">import Head from 'next\/head';\r\nimport { Post } from '..\/components\/Post';\r\nimport { Main } from '..\/layouts\/Main';\r\n\r\n\r\nexport default function Home() {\r\n return (\r\n   &lt;&gt;\r\n     &lt;Head&gt;\r\n       &lt;title&gt;Blog NextJS&lt;\/title&gt;\r\n       &lt;meta name=\"description\" content=\"Generated by create next app\" \/&gt;\r\n       &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" \/&gt;\r\n       &lt;link rel=\"icon\" href=\"\/favicon.ico\" \/&gt;\r\n     &lt;\/Head&gt;\r\n     &lt;Main&gt;\r\n       &lt;Post \/&gt;\r\n     &lt;\/Main&gt;\r\n   &lt;\/&gt;\r\n );\r\n}\r\n\r\n\r\n<\/pre>\n<h4>Components\/Post:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">import Link from 'next\/link';\r\nimport JSON_POSTS from '..\/..\/public\/data\/posts.json';\r\nexport type PostType = typeof JSON_POSTS[number];\r\nimport moment from 'moment';\r\nexport const Post = () =&gt; {\r\n return (\r\n   &lt;&gt;\r\n     &lt;div className=\"text-white py-4\"&gt;\r\n       &lt;h1 className=\"text-4xl\"&gt;Latest&lt;\/h1&gt;\r\n       &lt;div className=\"text-gray-500 py-4 border-b border-gray-700\"&gt;\r\n         A blog created with Next.js and Tailwind.css\r\n       &lt;\/div&gt;\r\n     &lt;\/div&gt;\r\n     {JSON_POSTS?.map((post) =&gt; {\r\n       return (\r\n         &lt;div key={post.id} className=\"py-10 border-b border-gray-700\"&gt;\r\n           &lt;div className=\"text-gray-500\"&gt;\r\n             {moment(post.created_at).fromNow()}\r\n           &lt;\/div&gt;\r\n           &lt;div className=\"text-white text-2xl py-2\"&gt;{post.title}&lt;\/div&gt;\r\n           &lt;div className=\"flex flex-wrap gap-4 text-emerald-600\"&gt;\r\n             &lt;div&gt;NEXT-JS&lt;\/div&gt;\r\n             &lt;div&gt;TAILWIND&lt;\/div&gt;\r\n             &lt;div&gt;FEATURE&lt;\/div&gt;\r\n           &lt;\/div&gt;\r\n           &lt;div className=\"text-gray-500 py-4\"&gt;{post.content}&lt;\/div&gt;\r\n           &lt;div className=\"text-emerald-600\"&gt;\r\n             &lt;Link href={`post\/${post.id}`}&gt;Read more \u2192&lt;\/Link&gt;\r\n           &lt;\/div&gt;\r\n         &lt;\/div&gt;\r\n       );\r\n     })}\r\n\r\n\r\n     &lt;div className=\"text-emerald-600 flex justify-end mt-4\"&gt;All Posts \u2192&lt;\/div&gt;\r\n   &lt;\/&gt;\r\n );\r\n};\r\n\r\n\r\n<\/pre>\n<h4><span style=\"font-weight: 400;\">Giao di\u1ec7n ho\u00e0n ch\u1ec9nh trang index:<\/span><\/h4>\n<figure id=\"attachment_3077\" aria-describedby=\"caption-attachment-3077\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175146\/hinh9-1-300x175.png\" alt=\"Giao di\u1ec7n ho\u00e0n ch\u1ec9nh trang index\" width=\"300\" height=\"175\" class=\"size-medium wp-image-3077\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175146\/hinh9-1-300x175.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175146\/hinh9-1-1024x598.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175146\/hinh9-1-768x449.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175146\/hinh9-1-1536x897.png 1536w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175146\/hinh9-1-1568x916.png 1568w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175146\/hinh9-1.png 1734w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3077\" class=\"wp-caption-text\">Giao di\u1ec7n ho\u00e0n ch\u1ec9nh trang index<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h2>C\u00e1c t\u00ednh n\u0103ng:<\/h2>\n<h3><span style=\"text-decoration: underline;\">T\u00ednh n\u0103ng Static Site Generation<\/span><\/h3>\n<figure id=\"attachment_3078\" aria-describedby=\"caption-attachment-3078\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175151\/hinh10-1-300x152.png\" alt=\"T\u00ednh n\u0103ng Static Site Generation\" width=\"300\" height=\"152\" class=\"size-medium wp-image-3078\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175151\/hinh10-1-300x152.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175151\/hinh10-1.png 663w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3078\" class=\"wp-caption-text\">T\u00ednh n\u0103ng Static Site Generation<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110\u1ec3 t\u1ea1o page chi ti\u1ebft c\u1ee7a b\u00e0i post: ch\u00fang ta ch\u1ec9 c\u1ea7n t\u1ea1o files nh\u01b0 sau: pages\/post\/[id].tsx (<\/span><b>File-system Routing<\/b><span style=\"font-weight: 400;\">)<\/span><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">import { PostDetail, PostType } from '..\/..\/components\/Post';\r\nimport type { GetStaticPaths, GetStaticProps } from 'next';\r\nimport type { ParsedUrlQuery } from 'querystring';\r\nimport JSON_POSTS from '..\/..\/public\/data\/posts.json';\r\n\r\n\r\ntype PostDetailPageType = {\r\n post: PostType;\r\n};\r\ntype Params = ParsedUrlQuery &amp; {\r\n id: string;\r\n};\r\nexport const getStaticPaths: GetStaticPaths = async () =&gt; {\r\n const ids = JSON_POSTS.map((c) =&gt; c.id);\r\n const paths = ids.map((id) =&gt; {\r\n   return {\r\n     params: { id: id.toString() },\r\n   };\r\n });\r\n return { paths, fallback: false };\r\n};\r\n\r\n\r\nexport const getStaticProps: GetStaticProps = async (context) =&gt; {\r\n const { id } = context.params as Params;\r\n const post = JSON_POSTS.find((c) =&gt; c.id.toString() === id);\r\n\r\n\r\n return {\r\n   props: { post },\r\n };\r\n};\r\nexport default function DetailPost({ post }: PostDetailPageType) {\r\n return (\r\n   &lt;&gt;\r\n     &lt;PostDetail post={post} \/&gt;\r\n   &lt;\/&gt;\r\n );\r\n}\r\n\r\n\r\n<\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u1ede \u0111\u00e2y, b\u1eb1ng c\u00e1ch k\u1ebft h\u1ee3p 2 h\u00e0m <\/span><b>GetStaticPaths v\u00e0 GetStaticProps <\/b><span style=\"font-weight: 400;\">\u0111\u1ec3 ch\u1ea1y \u1edf l\u00fac build time, nextJS s\u1ebd build cho ch\u00fang ta c\u00e1c page html t\u0129nh, \u0111\u00e2y l\u00e0 t\u00ednh n\u0103ng SSG n\u1ed5i tr\u1ed9i c\u1ee7a NextJS (Ho\u1eb7c Next JS s\u1ebd m\u1eb7c \u0111\u1ecbnh d\u00f9ng Automatic Static Generation khi kh\u00f4ng d\u00f9ng <\/span><b>getServerSideProps(SSR) <\/b><span style=\"font-weight: 400;\">\u0111\u1ec3 build ra c\u00e1c file html t\u0129nh<\/span><b>).<\/b><span style=\"font-weight: 400;\">\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 c\u00e1c trang html t\u0129nh c\u1ee7a c\u00e1c b\u00e0i post \u0111\u1ea7y \u0111\u1ee7 data \u0111\u01b0\u1ee3c build ra s\u1eb5n, cho n\u00ean khi nh\u1eadn request client s\u1ebd tr\u1ea3 v\u1ec1 ngay l\u1eadp t\u1ee9c.<\/span><\/li>\n<\/ul>\n<figure id=\"attachment_3079\" aria-describedby=\"caption-attachment-3079\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175155\/hinh11-1-300x157.png\" alt=\"SSR\" width=\"300\" height=\"157\" class=\"size-medium wp-image-3079\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175155\/hinh11-1-300x157.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175155\/hinh11-1-1024x534.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175155\/hinh11-1-768x401.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175155\/hinh11-1-1536x802.png 1536w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175155\/hinh11-1-1568x818.png 1568w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175155\/hinh11-1.png 1753w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3079\" class=\"wp-caption-text\">SSR<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110\u00e2y l\u00e0 c\u00e1ch Next.JS truy\u1ec1n d\u1eef li\u1ec7u t\u1eeb ph\u00eda server v\u1ec1 client, data s\u1ebd \u0111\u01b0\u1ee3c l\u01b0u v\u00e0o __NEXT_DATA__ \u0111\u1ec3 truy c\u1eadp khi c\u1ea7n thi\u1ebft.<\/span><\/li>\n<\/ul>\n<figure id=\"attachment_3080\" aria-describedby=\"caption-attachment-3080\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175201\/hinh12-1-300x151.png\" alt=\"Truy\u1ec1n d\u1eef li\u1ec7u t\u1eeb ph\u00eda server\" width=\"300\" height=\"151\" class=\"wp-image-3080 size-medium\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175201\/hinh12-1-300x151.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175201\/hinh12-1-1024x515.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175201\/hinh12-1-768x387.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175201\/hinh12-1-1536x773.png 1536w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175201\/hinh12-1-1568x789.png 1568w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175201\/hinh12-1.png 1774w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3080\" class=\"wp-caption-text\">Truy\u1ec1n d\u1eef li\u1ec7u t\u1eeb ph\u00eda server<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">Giao di\u1ec7n chi ti\u1ebft b\u00e0i post:<\/span><\/li>\n<\/ul>\n<figure id=\"attachment_3081\" aria-describedby=\"caption-attachment-3081\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175205\/hinh13-300x162.png\" alt=\"Giao di\u1ec7n b\u00e0i post\" width=\"300\" height=\"162\" class=\"size-medium wp-image-3081\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175205\/hinh13-300x162.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175205\/hinh13-1024x552.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175205\/hinh13-768x414.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175205\/hinh13-1536x828.png 1536w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175205\/hinh13-1568x845.png 1568w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175205\/hinh13.png 1729w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3081\" class=\"wp-caption-text\">Giao di\u1ec7n b\u00e0i post<\/figcaption><\/figure>\n<h3><span style=\"text-decoration: underline;\">T\u00ednh n\u0103ng Server Side Rendering<\/span><\/h3>\n<figure id=\"attachment_3082\" aria-describedby=\"caption-attachment-3082\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175209\/hinh14-300x164.png\" alt=\"T\u00ednh n\u0103ng Server Side Rendering:\" width=\"300\" height=\"164\" class=\"size-medium wp-image-3082\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175209\/hinh14-300x164.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175209\/hinh14.png 682w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3082\" class=\"wp-caption-text\">T\u00ednh n\u0103ng Server Side Rendering:<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ea1o th\u00eam th\u01b0 m\u1ee5c <\/span><b>pages\/article\/[id].tsx<\/b><span style=\"font-weight: 400;\"> \u0111\u1ec3 test t\u00ednh n\u0103ng n\u00e0y nh\u00e9.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Khi n\u00e0o th\u00ec h\u00e0m\u00a0 <\/span><b>getServerSideProps<\/b> <span style=\"font-weight: 400;\">run:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Khi b\u1ea1n request tr\u1ef1c ti\u1ebfp v\u00e0o trang n\u00e0y th\u00ec <\/span><b>getServerSideProps <\/b><span style=\"font-weight: 400;\">s\u1ebd run \u1edf l\u00fac request time v\u00e0 trang c\u1ee7a b\u1ea1n s\u1ebd \u0111\u01b0\u1ee3c pre-render v\u1edbi k\u1ebft qu\u1ea3 tr\u1ea3 v\u1ec1 l\u00e0 props.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Khi b\u1ea1n request trang n\u00e0y \u1edf client side th\u00f4ng quan next\/link, next\/router NextJS s\u1ebd g\u1eedi request API \u0111\u1ebfn server v\u00e0 server s\u1ebd ch\u1ea1y <\/span><b>getServerSideProps.<\/b><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">H\u00e0m <\/span><b>getServerSideProps<\/b><span style=\"font-weight: 400;\"> n\u00e0y ch\u1ec9 s\u1eed d\u1ee5ng \u1edf server side v\u00e0 ch\u1ec9 \u0111\u01b0\u1ee3c d\u00f9ng trong th\u01b0 m\u1ee5c pages, \u1edf l\u00fac runtime khi server nh\u1eadn request s\u1ebd th\u1ef1c hi\u1ec7n l\u1ea5y data v\u00e0 build th\u00e0nh file html tr\u1ea3 v\u1ec1 client.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 d\u00f9ng t\u00ednh n\u0103ng cache-control c\u1ee7a NextJS \u0111\u1ec3 t\u0103ng th\u00eam hi\u1ec7u su\u1ea5t<\/span><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">import { PostDetail, PostType } from '..\/..\/components\/Post';\r\n\r\n\r\nimport JSON_POSTS from '..\/..\/public\/data\/posts.json';\r\n\r\n\r\ntype DetailArticlePageType = {\r\n post: PostType;\r\n};\r\n\r\n\r\nexport async function getServerSideProps({ params }: any) {\r\n const dataPost = JSON_POSTS.find((item) =&gt; item.id == params.id) || {};\r\n return {\r\n   props: {\r\n     post: dataPost,\r\n   },\r\n };\r\n}\r\nexport default function DetailArticle({ post }: DetailArticlePageType) {\r\n return (\r\n   &lt;&gt;\r\n     &lt;PostDetail post={post} \/&gt;\r\n   &lt;\/&gt;\r\n );\r\n}\r\n\r\n\r\n<\/pre>\n<figure id=\"attachment_3083\" aria-describedby=\"caption-attachment-3083\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175211\/hinh15-300x119.png\" alt=\"Blog Next.JS\" width=\"300\" height=\"119\" class=\"size-medium wp-image-3083\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175211\/hinh15-300x119.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175211\/hinh15-1024x405.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175211\/hinh15-768x304.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175211\/hinh15-1536x607.png 1536w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175211\/hinh15-1568x620.png 1568w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175211\/hinh15.png 1722w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3083\" class=\"wp-caption-text\">Blog Next.JS<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h3><span style=\"text-decoration: underline;\">T\u00ednh n\u0103ng Client Side Rendering<\/span><\/h3>\n<figure id=\"attachment_3084\" aria-describedby=\"caption-attachment-3084\" style=\"width: 203px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175215\/hinh16-203x300.png\" alt=\"T\u00ednh n\u0103ng Client Side Rendering:\" width=\"203\" height=\"300\" class=\"size-medium wp-image-3084\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175215\/hinh16-203x300.png 203w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175215\/hinh16.png 632w\" sizes=\"auto, (max-width: 203px) 100vw, 203px\" \/><figcaption id=\"caption-attachment-3084\" class=\"wp-caption-text\">T\u00ednh n\u0103ng Client Side Rendering:<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u00ednh n\u0103ng n\u00e0y r\u1ea5t h\u1eefu \u00edch khi trang kh\u00f4ng c\u1ea7n index SEO, kh\u00f4ng c\u1ea7n pre-render ho\u1eb7c n\u1ed9i dung update th\u01b0\u1eddng xuy\u00ean, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng n\u00f3 \u1edf level component.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Data s\u1ebd \u0111\u01b0\u1ee3c fetch \u1edf l\u00fac runtime (at time component mount) v\u00e0 render l\u1ea1i khi data change.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Nh\u01b0ng ph\u1ea3i l\u01b0u \u00fd, s\u1eed d\u1ee5ng CSR c\u00f3 th\u1ec3 l\u00e0m \u1ea3nh h\u01b0\u1edfng performance c\u1ee7a h\u1ec7 th\u1ed1ng, th\u1eddi gian load trang.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">B\u00ean c\u1ea1nh \u0111\u00f3 data fetch s\u1ebd kh\u00f4ng \u0111\u01b0\u1ee3c cache l\u1ea1i. B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng SWR c\u1ee7a nextJS \u0111\u1ec3 handle \u0111\u01b0\u1ee3c ph\u1ea7n n\u00e0y.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ea1o th\u00eam th\u01b0 m\u1ee5c <\/span><b>pages\/item\/[id].tsx<\/b><span style=\"font-weight: 400;\"> \u0111\u1ec3 test t\u00ednh n\u0103ng n\u00e0y nh\u00e9.<\/span><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">import { PostDetail, PostType } from '..\/..\/components\/Post';\r\nimport { useRouter } from 'next\/router';\r\nimport JSON_POSTS from '..\/..\/public\/data\/posts.json';\r\nimport { useEffect, useState } from 'react';\r\n\r\n\r\nexport default function DetailArticle() {\r\n const router = useRouter();\r\n const { id } = router.query;\r\n const [post, setPost] = useState&lt;PostType&gt;();\r\n const [isLoading, setLoading] = useState(false);\r\n\r\n\r\n useEffect(() =&gt; {\r\n   i if (isLoading) return &lt;p&gt;Loading...&lt;\/p&gt;;\r\n\r\n\r\n return &lt;&gt;{post !== undefined ? &lt;PostDetail post={post} \/&gt; : ''}&lt;\/&gt;;\r\n}f (!router.isReady) return;\r\n   setLoading(true);\r\n   const dataPost = JSON_POSTS.find(\r\n     (item) =&gt; item.id.toString() === id?.toString()\r\n   );\r\n   setPost(dataPost);\r\n   setLoading(false);\r\n }, [router.isReady]);\r\n\r\n\r\n\r\n<\/pre>\n<figure id=\"attachment_3085\" aria-describedby=\"caption-attachment-3085\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175217\/hinh17-300x179.png\" alt=\"Blog Next.JS\" width=\"300\" height=\"179\" class=\"size-medium wp-image-3085\" srcset=\"https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175217\/hinh17-300x179.png 300w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175217\/hinh17-1024x611.png 1024w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175217\/hinh17-768x458.png 768w, https:\/\/mevn-public.s3-ap-southeast-1.amazonaws.com\/marketenterprise.vn\/wp-images\/2023\/02\/16175217\/hinh17.png 1258w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-3085\" class=\"wp-caption-text\">Blog Next.JS<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h2>T\u1ed5ng k\u1ebft<\/h2>\n<p><span style=\"font-weight: 400;\">Nh\u01b0 v\u1eady, NextJS ngo\u00e0i vi\u1ec7c cung c\u1ea5p cho ch\u00fang ta r\u1ea5t nhi\u1ec1u t\u00ednh n\u0103ng h\u1eefu \u00edch th\u00ec n\u00f3 c\u00f2n l\u00e0 m\u1ed9t <a href=\"https:\/\/www.marketenterprise.vn\/blog\/gioi-thieu-ve-nextjs-phan-1.html\">framework<\/a> tri\u1ec3n khai nhanh ch\u00f3ng, mang hi\u1ec7u su\u1ea5t cao.\u00a0 Hy v\u1ecdng qua b\u00e0i vi\u1ebft gi\u00fap c\u00e1c b\u1ea1n hi\u1ec3u c\u01a1 b\u1ea3n v\u1ec1 c\u00e1c t\u00ednh n\u0103ng c\u1ee7a NextJS.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Link github project: <\/span><a href=\"https:\/\/github.com\/hochituong96\/blog-nextjs\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/github.com\/hochituong96\/blog-nextjs<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400;\">C\u00e1c b\u1ea1n \u0111\u1ecdc th\u00eam t\u00e0i li\u1ec7u \u1edf trang ch\u1ee7 NextJS nh\u00e9:\u00a0 <\/span><a href=\"https:\/\/nextjs.org\/docs\/getting-started\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/nextjs.org\/docs\/getting-started<\/span><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>C\u00e1c b\u00e0i vi\u1ebft v\u1ec1 NextJS :<\/p>\n<p>Ph\u1ea7n 1 : <a href=\"https:\/\/www.marketenterprise.vn\/blog\/gioi-thieu-ve-nextjs-phan-1.html\">Gi\u1edbi thi\u1ec7u v\u1ec1 NextJS<\/a><\/p>\n<p>Ph\u1ea7n 2: <a href=\"https:\/\/www.marketenterprise.vn\/blog\/tinh-nang-noi-bat-nextjs-phan-2.html\">T\u00ednh n\u0103ng n\u1ed5i b\u1eadt NextJS<\/a><\/p>\n<p>Ph\u1ea7n 3: Build Blog \u0111\u01a1n gi\u1ea3n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u1ede c\u00e1c ph\u1ea7n tr\u01b0\u1edbc ch\u00fang ta \u0111\u00e3 t\u00ecm hi\u1ec3u c\u01a1 b\u1ea3n v\u1ec1 NextJS, \u0111\u1ec3 gi\u1edbi thi\u1ec7u h\u1ebft t\u1ea5t t\u1ea7n t\u1eadt v\u1ec1 Next JS ch\u1eafc ch\u00fang ta c\u1ea7n ph\u1ea3i th\u00eam v\u00e0i b\u00e0i vi\u1ebft n\u1eefa, n\u00ean ch\u00fang ta h\u00e3y b\u1eaft tay v\u00e0o project \u0111\u01a1n gi\u1ea3n ngay cho n\u00f3ng n\u00e0o.<\/p>\n","protected":false},"author":46,"featured_media":3042,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[39,139,128,140,22],"class_list":["post-3068","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-gioi-thieu","tag-nextjs","tag-react","tag-tailwind-css","tag-technical"],"_links":{"self":[{"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/posts\/3068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/comments?post=3068"}],"version-history":[{"count":0,"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/posts\/3068\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/media\/3042"}],"wp:attachment":[{"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/media?parent=3068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/categories?post=3068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.marketenterprise.vn\/blog\/wp-json\/wp\/v2\/tags?post=3068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}