Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Added --no-gitignore option"v8.6.431/03/2026
- "Added init command content"v7.5.930/12/2025
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
Initialise Intlayer
Copy the code to the clipboard
npx intlayer initThe init command automatically configures Intlayer for your project by creating necessary files and settings. This is the recommended way to start with Intlayer.
Aliases:
npx intlayer init
Arguments:
--project-root [projectRoot]- Optional. Specify the project's root directory. If not provided, the command will search for the project root starting from the current working directory.--no-gitignore- Optional. Skips the automatic update of the.gitignorefile. If this flag is set,.intlayerwill not be added to.gitignore.
What it does:
The init command performs the following setup tasks:
- Validates project structure - Ensures you are in a valid project directory with a
package.jsonfile. - Updates
.gitignore- Adds.intlayerto your.gitignorefile to exclude generated files from version control (can be skipped with--no-gitignore). - Configures TypeScript - Updates any
tsconfig.jsonfiles to include the Intlayer type definitions (.intlayer/**/*.ts). - Creates configuration file - Generates
intlayer.config.ts(for TypeScript projects) orintlayer.config.mjs(for JavaScript projects) with default settings. - Updates Vite configuration - If a Vite config file is detected, it adds the import for the
vite-intlayerplugin. - Updates Next.js configuration - If a Next.js config file is detected, it adds the import for the
next-intlayerplugin.
Examples:
Basic initialisation:
Copy the code to the clipboard
npx intlayer initThis initialises Intlayer in the current directory, with automatic project root detection.
Initialisation with a custom project root:
Copy the code to the clipboard
npx intlayer init --project-root ./my-projectThis initialises Intlayer in the specified directory.
Initialisation without updating .gitignore:
Copy the code to the clipboard
npx intlayer init --no-gitignoreThis will set up all configuration files but will not modify your .gitignore file.
Output Example:
Copy the code to the clipboard
npx intlayer initChecking Intlayer configuration...✓ Added .intlayer to .gitignore✓ Updated tsconfig.json to include intlayer types✓ Created intlayer.config.ts✓ Injected import into vite.config.ts✓ Intlayer init setup complete.Notes:
- The command is idempotent - you can safely run it multiple times. Already configured steps will be automatically skipped.
- If a configuration file already exists, it will not be overwritten.
- TypeScript configurations without an
includearray (e.g. solution-style configurations with references) are skipped. - The command stops with an error if no
package.jsonis found in the project root.