Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Next.js React SnippetsNew to Visual Studio Code? Get it now.
Next.js React Snippets

Next.js React Snippets

Erick Escriba

|
451 installs
| (0) | Free
Next.js, React, typescript and javascript useful snippets
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Usage Guide

Installation

  • Install the VSCode extension
  • Reload VSCode
  • Snippets are ready 🎉

Usage

React

JavaScript

  1. rimr (Import React)

    import React from "react";
    
  2. rimrd (Import ReactDOM)

    import ReactDOM from "react-dom";
    
  3. rimrs (Import React and useState)

    import React, { useState } from "react";
    
  4. rimrse (Import React, useState and useEffect)

    import React, { useState, useEffect } from "react";
    
  5. rfc (React functional component)

    const Component = () => {
      return <div></div>;
    };
    export default Component;
    
  6. rue (useEffect hook)

    useEffect(() => {}, []);
    
  7. rus (useState hook)

    const [state, setState] = useState(initialValue);
    
  8. ruc (useContext hook)

    const value = useContext(myContext);
    
  9. rur (useRef hook)

    const refContainer = useRef(initialValue);
    

TypeScript

  1. rfcet (React functional component)

    import React from "react";
    
    interface Props {}
    
    function Component({}: Props) {
      return <div></div>;
    }
    
    export default Component;
    
  2. ruet (useEffect hook)

    useEffect(() => {}, []);
    
  3. rust (useState hook)

    const [state, setState] = useState(initialValue);
    
  4. ruct (useContext hook)

    const value = useContext(myContext);
    
  5. rurt (useRef hook)

    const refContainer = useRef(initialValue);
    

NextJS

JavaScript

  1. ngss (Next.js get server side props)

    export const getServerSideProps = async (context) => {
      return {
        props: {},
      };
    };
    
  2. ngsp (Next.js get static props)

    export const getStaticProps = async (context) => {
      return {
        props: {},
      };
    };
    
  3. ncapp (Next.js custom app)

    const MyApp = ({ Component, pageProps }) => {
      return <Component {...pageProps} />;
    };
    
    export default MyApp;
    
  4. ncdoc (Next.js custom document)

    import Document, { Html, Main, NextScript } from "next/document";
    const Document: Document = () => {
      return (
        <Html lang="en">
          <body>
            <Main />
            <NextScript />
          </body>
        </Html>
      );
    };
    
    export default Document;
    
  5. ngspa (Next.js get static path)

    export const getStaticPaths = async () => {
      return {
          paths:[${1}],
          fallback:false
        };
    };
    

TypeScript

  1. ngsst (Next.js get server side props)

    export const getServerSideProps: GetServerSideProps = async (context) => {
      return { props: {} };
    };
    
  2. ngspt (Next.js get static props)

    export const getStaticProps: getStaticProps = async (context) => {
      return { props: {} };
    };
    
  3. npt (Next.js page)

    import type { NextPage } from "next";
    const Page: NextPage = () => {
      return <></>;
    };
    export default Page;
    
  4. ngipt (Next.js get initial props)

    Page.getInitialProps = async (context) => {
      return { props: {} };
    };
    
  5. nct (Next.js component)

    import type { NextComponentType, NextPageContext } from "next";
    interface Props {}
    const Component: NextComponentType<NextPageContext, {}, Props> = (
      props: Props
    ) => {
      return <div></div>;
    };
    export default Component;
    
  6. ngspat (Next.js Get Static Path Typescript)

    export const getStaticPaths: GetStaticPaths = async () => {
      return {
        paths:[${1}],
        fallback:false
      };
    }
    
  7. ncappt (Next.js custom app)

    const MyApp = ({ Component, pageProps }) => {
      return <Component {...pageProps} />;
    };
    export default MyApp;
    
  8. ncdoct(Next.js custom document)

    import Document, { Html, Main, NextScript } from "next/document";
    const Document: Document = () => {
      return (
        <Html lang="en">
          <body>
            <Main />
            <NextScript />
          </body>
        </Html>
      );
    };
    
    export default Document;
    
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft