-
Install Next.js and TypeScript SDK:
- Download and install Next.js 14 from the official website.
- Install TypeScript and the TypeScript SDK using npm commands:
npm install npm install ts-node ts-config
-
Set Up Next.js with TypeScript:
- In the Next.js source directory, create a
.tsconfigfile in thebin/sectiondirectory.touch bin/section/.tsconfig
- Configure Next.js to use TypeScript with:
node -e 'import { jsconfig } from 'tsconfig'; jsconfig.config = { options: { type: 'typescript' } };' node create jsconfig file:bin/section/.tsconfig'
- In the Next.js source directory, create a
-
Install Next.js with TypeScript Support:
- Use the Next.js 14 installation script to include TypeScript:
npm install --production ts-node ts-config
- Use the Next.js 14 installation script to include TypeScript:
-
Install Hiddify:
- Download the latest version of Hiddify from the official GitHub repository.
- Install the package with:
npm install hiddify@latest
-
Configure Next.js for Hiddify:
- Create a
tsconfig.jsonfile in thebin/sectiondirectory:touch bin/section/.tsconfig
- Add the following configuration:
{ "typescript": { "module": "hiddify", "version": "6..", "baseDir": "C:/path/to/nextjs-14-typescript", "rootDir": "C:/path/to/nextjs-14-typescript/src", "envDir": "C:/path/to/nextjs-14-typescript/src", "envName": "typescript", "rootDir": "C:/path/to/nextjs-14-typescript/src", "rootDir": "C:/path/to/nextjs-14-typescript/src", "rootDir": "C:/path/to/nextjs-14-typescript/src", } }Replace the path with your actual Next.js 14 source directory.
- Create a
-
Set Up Environment Variables:
- Add the following environment variable to your Next.js configuration:
export HIDDIFY_HINTify_CONFIG_FILE=C:/path/to/nextjs-14-typescript/.tsconfig
- Create a
.envfile in your Next.js project root with this variable:echo "export HIDDIFY_HINTIFY_CONFIG_FILE=C:/path/to/nextjs-14-typescript/.tsconfig" > .env
- Add the following environment variable to your Next.js configuration:
-
Verify Configuration:
- Check if Next.js is configured correctly by running:
node -e "import { jsconfig } from 'tsconfig'; console.log(jsconfig.config.type;" - This should output "typescript".
- Check if Next.js is configured correctly by running:
-
Use Hiddify:
- Start Next.js with TypeScript:
npm start
- Use Hiddify features to type your Next.js code.
- Start Next.js with TypeScript:
-
Additional Setup:
If needed, set up TypeScript options for your project. Use Hiddify's TypeScript configuration to customize your project's type definitions.
-
Test and Debug:
- Use Next.js's built-in debug mode and TypeScript options to ensure your code is properly typed.
- Check for any runtime errors or warnings related to TypeScript.
By following these steps, you should successfully integrate Hiddify into your Next.js project, enhancing type safety through TypeScript integration.




