Skip to content

denwa-web-shared

A shared library for Next.js App Router projects containing reusable components, hooks, schemas, and utilities.

shared-constants

core
60 linesSource

Use shared library constants like TIME and THEME. Load when hardcoding time durations, milliseconds, breakpoints, or offsets.

denwa-web-shared — Use library constants

Setup

tsx
import { TIME, THEME } from 'denwa-web-shared/server';

const timeout = TIME.milliseconds.seconds5;
const offset = THEME.OFFSET[4];

Core Patterns

Using TIME constants for durations

tsx
import { TIME } from 'denwa-web-shared/server';

export const fetchWithTimeout = async (url: string) => {
  const controller = new AbortController();
  setTimeout(() => controller.abort(), TIME.milliseconds.seconds5);

  return fetch(url, { signal: controller.signal });
};

Common Mistakes

MEDIUM Hardcoding time values

Wrong:

tsx
setTimeout(fn, 1000);

Correct:

tsx
import { TIME } from 'denwa-web-shared/server';

setTimeout(fn, TIME.milliseconds.seconds1);

Agents hardcode milliseconds values instead of using the TIME constant.

Source: maintainer interview