Skip to main content

Prerequisites

Pion WebRTC v4 requires Go 1.24.0 or later. Make sure you have a compatible Go version installed.
1

Check Go Version

Verify your Go installation:
You should see output like go version go1.24.0 or higher.
2

Enable Go Modules

Go modules are mandatory for Pion WebRTC. Ensure they’re enabled:
In Go 1.16+, modules are enabled by default. You only need to set this if you’re using an older version.

Install Pion WebRTC

Add Pion WebRTC to your project with a single command:
Important: Always specify the /v4 suffix when importing. This ensures you get the latest v4 release.

Initialize a New Project

If you’re starting a new project:

Version Management

Using Specific Versions

To use a specific version of Pion WebRTC:

Using v3 (Legacy)

If you’re not ready to upgrade to v4, you can still use v3 releases:
Check the v3 tags for the latest v3 release.

Dependencies

Pion WebRTC automatically manages its dependencies through Go modules. Core dependencies include:
  • pion/datachannel (v1.6.0) - SCTP DataChannel implementation
  • pion/dtls/v3 (v3.1.2) - DTLS 1.2 protocol
  • pion/ice/v4 (v4.2.1) - ICE (Interactive Connectivity Establishment)
  • pion/interceptor (v0.1.44) - RTP/RTCP interceptor framework
  • pion/rtp (v1.10.1) - RTP packet processing
  • pion/rtcp (v1.2.16) - RTCP packet processing
  • pion/sctp (v1.9.2) - SCTP protocol implementation
  • pion/sdp/v3 (v3.0.18) - SDP parsing and generation
  • pion/srtp/v3 (v3.0.10) - SRTP encryption
  • pion/stun/v3 (v3.1.1) - STUN protocol
  • pion/turn/v4 (v4.1.4) - TURN relay protocol
  • pion/transport/v4 (v4.0.1) - Network transport utilities
  • pion/logging (v0.2.4) - Logging interface
  • pion/randutil (v0.1.0) - Random number utilities
  • golang.org/x/net (v0.50.0) - Network extensions
All dependencies are automatically downloaded when you run go get or go build.

Importing in Your Code

Import Pion WebRTC in your Go files:
Always remember to specify /v4 in your import path:

Additional Packages

Pion provides additional packages for media handling:

Media Utilities

For reading and writing media files:

Media Devices (Requires CGo)

The media devices package requires CGo and is only available on select platforms.
For capturing audio/video from hardware devices:

Platform-Specific Notes

No additional dependencies required. Pion WebRTC works out of the box.

Verify Installation

Create a simple test file to verify your installation:
Expected output:

Build Configuration

Optimized Builds

For production builds, use optimizations:

Build Times

Performance benchmarks (on Intel Core i5-2520M @ 2.50GHz):
  • Time to build examples: ~0.28 seconds
  • Time to run full test suite: ~77 seconds

Troubleshooting

Make sure Go modules are enabled:
Ensure you’re using the correct import path with /v4:
Pion WebRTC v4 requires Go 1.24.0+. Upgrade Go or use v3:
Clear your module cache and retry:

Next Steps

Quick Start Guide

Build your first WebRTC application with a step-by-step tutorial

Browse Examples

Explore 30+ working examples covering common use cases

API Documentation

Dive into the complete API reference

Join Community

Get help and share your projects on Discord