Generate migrations with:
pnpm drizzle-kit generate:pg
Run with:
pnpm tsx ./migrate.ts
Generate migrations with:
pnpm drizzle-kit generate:pg
Run with:
pnpm tsx ./migrate.ts
import { Suspense } from "react"; | |
import CurrentTimeClient from "./CurrentTimeClient"; | |
export default function CurrentTime() { | |
const locale = "en-GB"; | |
const dateConfig = { | |
hour: "numeric", | |
minute: "numeric", | |
second: "numeric", |
"use client"; | |
import { cache, unstable_postpone } from "react"; | |
import { preload } from "react-dom"; | |
const loadImage = cache((src: string) => { | |
return new Promise<void>((resolve, reject) => { | |
const img = new Image(); | |
img.src = src; |
import { useRef, useCallback, useInsertionEffect } from "react"; | |
// Approximation of React's upcoming useEffectEvent hook | |
// This gives us a non-reactive effect event callback, it will always use the latest version of | |
// the callback, rather than the one that was closed over. | |
export default function useEffectEventShim<T extends (...args: any[]) => any>( | |
fn: T | |
): (...funcArgs: Parameters<T>) => ReturnType<T> { | |
const ref = useRef(fn); |
A simple sketch of how we migrate a "card" component to lazy-load its popover content by server actions. The after (lazy) version is visibly more complex, but the steps involved are fairly straightforward -- and if it were a common pattern, there are steps that could be taken to abstract it into something simpler.
Important to note that if it's determined that server actions can only be defined in server components, the solution would be a little different.
import { AwsClient } from "aws4fetch"; | |
import { deflate } from "pako"; | |
const R2_ACCOUNT_ID = "SOMETHING" | |
const R2_ACCESS_KEY_ID = "SOMETHING" | |
const R2_SECRET_ACCESS_KEY ="SOMETHING" | |
const R2_BUCKET = "SOMETHING" | |
const R2_URL = `https://${R2_BUCKET}.${R2_ACCOUNT_ID}.r2.cloudflarestorage.com`; | |
import { SitemapStream, EnumChangefreq } from "sitemap"; | |
import { getAllPosts } from "~/data"; | |
import { Readable } from "node:stream"; | |
async function* getSitemapUrls(request: Request) { | |
const url = new URL(request.url); | |
const origin = `${url.protocol}//${url.host}`; |
import { SitemapStream, EnumChangefreq, streamToPromise } from "sitemap"; | |
import { getAllPosts } from "~/data"; | |
import { Readable } from "stream"; | |
async function* getSitemapUrls(request: Request) { | |
const url = new URL(request.url); | |
const origin = `${url.protocol}//${url.host}`; |
import { use } from "react"; | |
type Props<T> = { | |
resolve: Promise<T>; | |
children: (value: T) => React.ReactElement; | |
}; | |
export default function Await<T>({ resolve, children }: Props<T>) { | |
const value = use(resolve); |
Note: API routes are still only supported in the pages
folder, not app
.
I was playing around with using API routes with the experimental app dir stuff in Next 13, and I was frustrated at having to use completely different code paths for accessing the request headers and cookies compared to in server components. So I hacked together a workaround which you definitely shouldn't use.
Usage requires two steps, one is easy, the other is invasive: