Docs
Recipes
Next JS Integration

Brail + Next.js

Brail is intended to be framework agnostic, but has been developed with next.js in mind.

The below configuration allows us to automatically generate a file with all of our templates.

/* 📄 next.config.mjs */
import { withBrail } from "brail/next"
 
const brailConfig = {
	// templateExtensions: string[] | undefined
	// Narrow which files in the project should be considered templates
	templateExtensions: ["template.tsx"]
 
	// brailDir: string | undefined
	// Specify where any brail files will be stored
	brailDir: "some/dir",
 
	// emitTemplates: string | boolean | undefined
	// Whether/where to emit templates
	emitTemplates: "some/dir/path.ts"
}
 
export default withBrail(brailConfig)({
	/* Your next.js config */
});

With the above config we could import our templates for use from the some/dir/path.ts file, which would have a generated export along the lines of:

export const templates = {
  /** Nested record of templates */
};