A compact collection of VS Code snippets for React and Next.js (JavaScript & TypeScript) — productivity shortcuts for pages, components, hooks and API routes.
- Install from the VS Code Marketplace (search React and Next.js Snippets) or install locally:
- Clone the repo:
git clone <repo> - Open in VS Code and run the Run Extension debug target or package a VSIX and install with
code --install-extension <file>.vsix.
- Clone the repo:
- Trigger any snippet by typing its
prefixand pressing Tab. - See the full list in
SNIPPETS.mdorsrc/extension/snippets/.
- Ready-to-use snippets for common React patterns (functional components, hooks) and Next.js (pages, getStaticProps, API routes).
- Supports JavaScript and TypeScript variants.
- Small, focused, easy to extend.
- Create a React functional component: type
rfc(JS) orrfct(TS) + Tab. - Create a Next.js page: type
npt(TS) ornpt(JS) + Tab.
Full prefix table: see SNIPPETS.md.
Commands
- Install & setup hooks:
yarn(ornpm install) - Regenerate snippet docs:
yarn generateReadme - Format:
yarn format - Pre-commit: runs
generateReadme+format(seeprepare/ husky)
How to add a snippet
- Add a JSON entry in
src/extension/snippets/<language>.json(follow existing format). - Run
yarn generateReadmeto updateSNIPPETS.mdandsrc/extension/README.md. - Run
yarn formatand open a PR with a short description and example usage.
Local testing
- Open the repository in VS Code and press F5 to launch an Extension Development Host where snippets are available.
src/extension/snippets/— snippet definitions (JSON)SNIPPETS.md— generated snippet tablesrc/automation/scripts/generateReadme.js— generator used by pre-commit
- License mismatch (HIGH) —
LICENSEis GPL‑3.0 butpackage.jsonlists MIT. Action: decide intended license and make them consistent (recommended: updatepackage.jsontoGPL-3.0-or-lateror replace LICENSE if MIT was intended). - README generator: off-by-one snippet count (MEDIUM) —
generateReadme.jscounts the header row when reporting total snippets. Fix: subtract 1 from the displayed count. - README generator: race-condition (MEDIUM → HIGH for CI) — generator starts concurrent reads and writes the README from each file-callback; it can produce incomplete output. Fix: process files sequentially or use
Promise.alland write only after all files are processed. - Inefficient / redundant writes (LOW) — generator calls
fs.writeFile(..., "")before writing final content; remove the redundant call. - Documentation parity (LOW) —
SNIPPETS.mdcurrently reports38 snippetsbut there are 37 snippet entries across the snippet JSON files (generator bug causes +1).
Would you like me to open a PR that implements items (1)–(4)? I can prepare a minimal, well-tested patch.
- Read
CODE_OF_CONDUCT.mdand open a small PR for changes. - Add tests or a CI check to validate snippet JSON shape and ensure
yarn generateReadmeoutput is deterministic.
This repository includes a LICENSE file. Important: there is currently a mismatch between LICENSE and package.json — see Audit summary above. Please resolve before publishing.
- Avneesh Agarwal (original author)
If you want, I can:
- Apply the critical fixes and submit a PR ✅
- Add a CI job that runs
yarn generateReadmeand fails if the README is out-of-date ✅