Introduction | lighthouse-go | Spatie       

 SPATIE  

lighthouse-go
=============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Lighthouse-go](https://spatie.be/docs/lighthouse-go/v1)  Introduction

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/lighthouse-go/v1) 

  Introduction    
- [ Introduction ](https://spatie.be/docs/lighthouse-go/v1/introduction)
- [ Requirements ](https://spatie.be/docs/lighthouse-go/v1/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/lighthouse-go/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/lighthouse-go/v1/questions-issues)
- [ Differences from PHP ](https://spatie.be/docs/lighthouse-go/v1/go-differences)
- [ Testing ](https://spatie.be/docs/lighthouse-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/lighthouse-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/lighthouse-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/lighthouse-go/v1/support-us)
- [ About us ](https://spatie.be/docs/lighthouse-go/v1/about-us)

Usage
-----

- [ Generating your first report ](https://spatie.be/docs/lighthouse-go/v1/usage/generating-your-first-report)
- [ Configuring a run ](https://spatie.be/docs/lighthouse-go/v1/usage/configuring-a-run)
- [ Working with results ](https://spatie.be/docs/lighthouse-go/v1/usage/working-with-results)
- [ Saving an HTML report ](https://spatie.be/docs/lighthouse-go/v1/usage/saving-an-html-report)
- [ Using performance budgets ](https://spatie.be/docs/lighthouse-go/v1/usage/using-performance-budgets)

  Lighthouse-go 
===============

 Run Google Lighthouse using Go 

### Useful links

- [Repository](https://github.com/spatie/lighthouse-go)
- [Discussions](https://github.com/spatie/lighthouse-go/discussions)

Introduction
------------

[Google Lighthouse](https://developer.chrome.com/docs/lighthouse/overview/) is an open-source, automated tool for improving the quality of web pages. It has audits for performance, accessibility, best practices, SEO and more.

This package makes it easy to run Lighthouse using Go. Here's how to get the scores of the four categories of audits that current Lighthouse offers.

```
run, err := lighthouse.New("https://example.com")
if err != nil {
    return err
}
result, err := run.Run(ctx)
if err != nil {
    return err
}
scores := result.Scores()
// Example: map[accessibility:92 best-practices:100 performance:100 seo:91]
```

Import `github.com/spatie/lighthouse-go` as `lighthouse`. Examples inside a function use a `context.Context` named `ctx` and return errors to the caller.

It's easy to configure various options.

```
run, err := lighthouse.New("https://example.com",
    lighthouse.UserAgent("My user agent"),
    lighthouse.Headers(map[string]string{"MyExtraHeader": "HeaderValue"}),
    lighthouse.Categories(lighthouse.Performance, lighthouse.Accessibility),
    lighthouse.ThrottleCPU(true, 4),
)
```

Here's how you can get the results of an audit.

```
audit, err := result.Audit("first-contentful-paint")
// Includes id, title, score, numericValue, numericUnit and displayValue.
```

You can also write a full HTML report to disk with `result.SaveHTML("report.html")`.

Start with [requirements](requirements) and [installation and setup](installation-setup), then [generate your first report](usage/generating-your-first-report). The [Go differences](go-differences) page describes deliberate differences from PHP and upstream version constraints.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
