> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lightning-go.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick start

> Create and run your first Lightning web service in under five minutes.

This guide walks you through creating a Lightning app from scratch, registering a route, and verifying the response with curl.

<Steps>
  <Step title="Install Lightning">
    Add Lightning to your Go module:

    ```bash theme={null}
    go get github.com/go-labx/lightning
    ```

    If you don't have a module yet, initialize one first:

    ```bash theme={null}
    mkdir myapp && cd myapp
    go mod init myapp
    go get github.com/go-labx/lightning
    ```
  </Step>

  <Step title="Create main.go">
    Create a file named `main.go` with the following content:

    ```go theme={null}
    package main

    import "github.com/go-labx/lightning"

    func main() {
        app := lightning.DefaultApp()

        app.Get("/ping", func(ctx *lightning.Context) {
            ctx.JSON(lightning.StatusOK, lightning.Map{
                "message": "pong",
            })
        })

        app.Run()
    }
    ```

    <Tip>
      `DefaultApp()` creates a new application with two middleware functions already registered: `Logger()`, which logs every request, and `Recovery()`, which catches panics and returns a 500 response. Use `NewApp()` if you want a bare application with no middleware.
    </Tip>
  </Step>

  <Step title="Run the server">
    Start the server:

    ```bash theme={null}
    go run main.go
    ```

    You should see output similar to:

    ```
    [lightning-app] INFO Starting application on address `:6789`
    ```

    <Note>
      Lightning listens on port **6789** by default. You can override this by passing an address to `app.Run()`, for example `app.Run(":8080")`, or by setting the `PORT` environment variable.
    </Note>
  </Step>

  <Step title="Test with curl">
    In a separate terminal, send a request to your running server:

    ```bash theme={null}
    curl http://127.0.0.1:6789/ping
    ```

    You should receive:

    ```json theme={null}
    {"message":"pong"}
    ```

    The server terminal will also print a log line for the request, showing the remote address, method, status code, path, and elapsed time.
  </Step>
</Steps>

## What's next

Now that your app is running, explore the core concepts:

* [Routing](/concepts/routing) — add URL parameters, wildcards, and multiple HTTP methods
* [Middleware](/concepts/middleware) — write custom middleware and apply it globally or to specific routes
* [Context API](/concepts/context) — read request data and send structured responses
* [Route groups](/concepts/groups) — organize routes under shared prefixes with scoped middleware
