Skip to main content

Import

import {
  defineConfig,
  json,
  notFound,
  redirect,
  getEnv,
  createValidatedHandler,
} from "veryfront";

Examples

Configuration

import { defineConfig } from "veryfront";

export default defineConfig({
  // your project config
});

API routes

import { json } from "veryfront";
import type { APIContext, APIResponse } from "veryfront";

export function GET(ctx: APIContext): APIResponse {
  return json({ message: "Hello" });
}

Data loading

import { notFound } from "veryfront";
import type { DataContext } from "veryfront";

export function getServerData(ctx: DataContext) {
  if (!ctx.params.id) throw notFound();
  return { title: "Page" };
}

Exports

Components

NameDescription
CommonSchemasBuilt-in Zod schemas (email, URL, etc.)
INPUT_VALIDATION_FAILEDHTTP request input validation failures (replaces ValidationError)

Functions

NameDescription
apiNotFound404 Not Found response
apiRedirectRedirect response
badRequest400 Bad Request response
createValidatedHandlerCreate a validated API handler wrapper that auto-validates body/query with Zod schemas
createValidationErrorCreate an input validation error.
createVeryfrontHandlerCreate HTTP request handler
defineConfigDefine project configuration
forbidden403 Forbidden response
getEnvRead environment variable (typed)
jsonJSON response helper
notFoundThrow 404 in data loaders
parseFormDataParse multipart form data
parseJsonBodyParse and validate JSON body
parseQueryParamsParse and validate query params
redirectThrow redirect in data loaders
sanitizeData****** Sanitize data to prevent XSS and prototype pollution attacks
serverError500 Internal Server Error response
startVeryfrontServerStart a Veryfront server in development or production mode.
unauthorized401 Unauthorized response

Types

NameDescription
APIContextAPI route handler context
APIHandlerAPI route handler signature
APIResponseAPI handler response type
APIRouteRoute with method handlers
DataContextgetServerData context
InferGetServerDataPropsUtility type to infer props from a page with data
MDXFrontmatterParsed MDX frontmatter
PageContextPage runtime context
PageWithDataPage with data fetching capabilities
StartVeryfrontServerOptionsServer options. Use mode: "development" for dev server with HMR,
StaticPathsResultgetStaticPaths return type
ValidatedHandlerConfigcreateValidatedHandler config
ValidatedHandlerFunctionHandler with validated inputs
VeryfrontConfigProject configuration shape
VeryfrontServerHandleServer handle (for shutdown)