Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

  • Gatsbyjs.com
    Gatsbyjs.com
  • Gatsby Cloud
    Gatsby Cloud
  • Documentation
    Documentation
  • Support
    Support
  • Contact
    Contact
  • Log in
    Log in
docs
    • Tutorial
      Tutorial
    • How-to Guides
      How-to Guides
    • Reference
      Reference
    • Conceptual Guide
      Conceptual Guide
    • Quick Start
      Quick Start
    • v3

      • v4 (beta)

        v4 (beta)

      • v3

        v3

      • v2

        v2

      • v1

        v1

DocumentationReference GuidesFunctions
Docs

Routing

Function routing shares the same syntax as page routing.

Both top-level and nested routes are supported.

  • src/api/top-level.js => /api/top-level
  • src/api/directory/foo.js => /api/directory/foo

index.js files are routed at their directory path e.g. src/api/users/index.js => /api/users

Edit this page on GitHub
  • Accessibility Statement
  • Code of Conduct
  • Logo & Assets
  • Privacy Policy
  Docs
  • Reference
    • Overview
    • Gatsby Project Structure
    • Gatsby CLI commands
    • Fast Refresh
    • Gatsby Link API
    • Gatsby Image plugin API
    • Creating Routes
    • File System Route API
    • Overview
    • Gatsby Config APIs
    • Gatsby Node APIs
    • Additional Guides 5
    • Overview
    • Getting Started
    • Routing
    • Middleware & Helpers
    • Overview
    • GraphQL Query API
    • GraphQL Query Options Reference
    • Customizing the GraphQL Schema
    • GraphQL Fragments
    • Additional Guides 2