Skip to content

Instantly share code, notes, and snippets.

View vanxh's full-sized avatar
👨‍💻
vanxh.dev

Vanxh vanxh

👨‍💻
vanxh.dev
View GitHub Profile
@vanxh
vanxh / .dockerignore
Last active April 16, 2024 22:18
Dockerfile to deploy NextJS using yarn v3 (berry) PnP.
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
# .next
.git
.DS_Store
.yarn/*
!.yarn/cache
@vanxh
vanxh / User.tsx
Last active January 3, 2023 20:49
Conditional custom hook data fetching in NextJS using SWR
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import useSWR from "swr";
import { getCookie } from "cookies-next";
import type { User } from "../lib/interfaces";
export default function useUser() {
const token = getCookie("token")?.toString();
const { data, error, mutate } = useSWR<{
user: User;
@vanxh
vanxh / Modal.tsx
Created January 3, 2023 20:41
Custom Next.JS (React.JS) modal using headless ui
import { Fragment } from "react";
import { Dialog, Transition } from "@headlessui/react";
const Modal = ({
open,
onClose,
title,
children,
}: {
open: boolean;