Configuration
Learn how to configure next-introspect for different analysis modes and output customization
Configuration
next-introspect offers extensive configuration options to customize analysis behavior and output formatting.
Analysis Modes
Basic Mode
Fastest analysis with essential route information.
next-introspect introspect . --mode basicIncludes:
- Route paths and patterns
- Basic route metadata
- Router type detection
Detailed Mode
Includes component analysis and extended metadata.
next-introspect introspect . --mode detailedIncludes:
- All basic mode data
- Component types (server/client)
- Special files detection
- Route groups and intercepting routes
Comprehensive Mode
Complete analysis with all available metadata.
next-introspect introspect . --mode comprehensiveIncludes:
- All detailed mode data
- Export analysis (metadata, generateStaticParams, etc.)
- Data fetching methods (getServerSideProps, getStaticProps)
- API route method detection
Path Display Options
Path Styles
Absolute Paths (Default)
next-introspect introspect . --path-style absoluteShows full absolute paths to files.
Relative to Project Root
next-introspect introspect . --path-style relative-to-projectShows paths relative to the project root directory.
Relative to App Directory
next-introspect introspect . --path-style relative-to-appShows paths relative to the app/ directory (App Router).
Relative to Pages Directory
next-introspect introspect . --path-style relative-to-pagesShows paths relative to the pages/ directory (Pages Router).
Strip Prefix
next-introspect introspect . --path-style strip-prefix --strip-prefix "src/"Removes specified prefix from paths.
Multiple Prefix Stripping
next-introspect introspect . --strip-prefixes "src/app/" "packages/"Package Information Display
Package Summary
next-introspect introspect . --package-summaryShows only essential package.json information:
- Name and version
- Dependency counts
- Framework detection
Include Scripts
next-introspect introspect . --package-summary --include-scriptsIncludes the scripts section in the summary.
Include Dependencies
next-introspect introspect . --package-summary --include-depsIncludes dependencies and devDependencies in the summary.
Output Formatting
Nested Structure
next-introspect introspect . --nested --format jsonOrganizes routes in a hierarchical structure instead of a flat array.
Include Empty Segments
next-introspect introspect . --nested --include-empty-segments --format jsonIncludes empty path segments in the nested structure.
Field Exclusion
next-introspect introspect . --exclude-fields "filePath,pattern,router"Excludes specified fields from the output. Useful for reducing payload size or focusing on specific data.
Common exclusions:
filePath- Remove file system pathspattern- Remove route pattern informationrouter- Remove router type informationdynamicSegments- Remove dynamic segment detailscomponentTypes- Remove component type analysis
TypeScript Strip Prefixes
next-introspect introspect . --format typescript --strip-prefixes "/api/" "/_next/"Removes specified prefixes from generated TypeScript route paths.
Metadata Integration
Metadata File
next-introspect introspect . --metadata metadata.jsonLoads additional metadata from a JSON file to enhance route information.
Metadata File Format
{
"/": {
"title": "Homepage",
"description": "Welcome to our website",
"category": "main"
},
"/blog/[slug]": {
"title": "Blog Post",
"description": "Read our latest blog posts",
"category": "content",
"authRequired": false
},
"/api/users": {
"title": "Users API",
"description": "User management endpoints",
"methods": ["GET", "POST", "PUT"],
"authRequired": true
}
}TOML Support
next-introspect also supports TOML format for metadata (basic support):
["/"]
title = "Homepage"
description = "Welcome to our website"
["/blog/[slug]"]
title = "Blog Post"
description = "Read our latest blog posts"Watch Mode Configuration
Basic Watch
next-introspect introspect . --watchWatch with Custom Output
next-introspect introspect . --watch --format typescript --output routes.tsQuiet Watch
next-introspect introspect . --watch --quiet --output routes.jsonWatched File Types
Watch mode monitors these file extensions:
.js,.jsx,.ts,.tsx- Route components and API handlers.json- Package.json and configuration files- Configuration files -
next.config.*,tsconfig.json
Ignored Directories
Automatically ignores:
node_modules/- Dependencies.next/- Build output.git/- Version controldist/- Distribution filesbuild/- Build artifacts
Programmatic Configuration
TypeScript Configuration
import { NextIntrospect } from 'next-introspect';
const introspect = new NextIntrospect('/path/to/project', {
// Analysis mode
mode: 'comprehensive',
// Path display configuration
pathDisplay: {
style: 'relative-to-project',
stripPrefix: 'src/',
showFilePaths: true
},
// Package display options
packageDisplay: {
includeFullDetails: false,
includeScripts: true,
includeDependencies: false
},
// Output formatting
outputFormat: {
nested: false,
includeEmptySegments: false,
excludeFields: ['filePath'],
stripPrefixes: ['/api/', '/_next/']
},
// Metadata integration
metadata: {
file: './metadata.json'
}
});Configuration Types
interface IntrospectionOptions {
mode?: 'basic' | 'detailed' | 'comprehensive';
maxDepth?: number;
followSymlinks?: boolean;
pathDisplay?: {
style?: 'absolute' | 'relative-to-project' | 'relative-to-app' | 'relative-to-pages' | 'strip-prefix';
stripPrefix?: string;
showFilePaths?: boolean;
};
packageDisplay?: {
includeFullDetails?: boolean;
includeScripts?: boolean;
includeDependencies?: boolean;
};
outputFormat?: {
nested?: boolean;
includeEmptySegments?: boolean;
excludeFields?: string[];
stripPrefixes?: string[];
};
metadata?: {
file?: string;
entries?: Record<string, RouteMetadata>;
};
}Environment-Specific Configuration
Development Configuration
const devConfig: IntrospectionOptions = {
mode: 'comprehensive',
pathDisplay: {
style: 'relative-to-project',
showFilePaths: true
},
outputFormat: {
excludeFields: []
}
};Production Configuration
const prodConfig: IntrospectionOptions = {
mode: 'basic',
pathDisplay: {
style: 'strip-prefix',
stripPrefix: '/app/',
showFilePaths: false
},
outputFormat: {
excludeFields: ['filePath', 'componentTypes']
}
};CI/CD Configuration
const ciConfig: IntrospectionOptions = {
mode: 'detailed',
outputFormat: {
nested: true,
excludeFields: ['filePath']
}
};Configuration File Support
next-introspect.config.js
module.exports = {
mode: 'comprehensive',
pathDisplay: {
style: 'relative-to-project',
showFilePaths: true
},
outputFormat: {
nested: false,
excludeFields: ['filePath']
},
metadata: {
file: './metadata.json'
}
};next-introspect.config.ts
import type { IntrospectionOptions } from 'next-introspect';
const config: IntrospectionOptions = {
mode: 'comprehensive',
pathDisplay: {
style: 'relative-to-project',
showFilePaths: true
},
outputFormat: {
excludeFields: ['filePath']
}
};
export default config;Performance Tuning
Fast Analysis
next-introspect introspect . --mode basic --quietMemory Optimization
next-introspect introspect . --exclude-fields "componentTypes,exports,dataFetching"Large Project Handling
next-introspect introspect . --mode basic --exclude-fields "filePath,dynamicSegments"Validation and Error Handling
Configuration Validation
next-introspect validates configuration options and provides helpful error messages:
Error: Invalid mode 'fast'. Valid modes: basic, detailed, comprehensive
Error: Invalid path style 'relative'. Valid styles: absolute, relative-to-project, relative-to-app, relative-to-pages, strip-prefixGraceful Degradation
If optional configuration files are missing, next-introspect continues with defaults:
# This works even if metadata.json doesn't exist
next-introspect introspect . --metadata metadata.jsonBest Practices
Development
- Use
--mode comprehensivefor full analysis during development - Use
--path-style relative-to-projectfor readable paths - Include
--show-file-pathsfor debugging
Production
- Use
--mode basicfor faster builds - Use
--exclude-fieldsto reduce output size - Use
--strip-prefixto normalize paths
CI/CD
- Use
--quietto reduce log noise - Use
--format jsonfor machine-readable output - Use
--outputto save results for later processing
Documentation
- Use
--format markdownfor human-readable docs - Use
--metadatato add descriptions and titles - Use
--nestedfor hierarchical route visualization