A reference to a navigator in view class

If I have a navigator attached to a UI class and two view classes how to get a reference of the navigator in the view classess?
Suppose that the views only have a button to pass to the other view

public myUI extends UI{
     Navigator nav;

     public init(VaadinRequest vaadinRequest){
          navigator = new Navigator(this, this);
          navigator.addView( "first", new FirstView());
          navigator.addView( "second", new SecondView());
public FirstView extends VerticalLayout implements View{
       private Button button;

       public FirstView(){
            button = new Button("Pass");
            button.addCliclListener( e -> nav.navigateTo("second") );
            // need the reference nav

In the documentation, the example the View classes are inner class of the UI.

It isn`t something like getNavigator of the current UI?

OK i found it in the API.


Note that instead of creating your views with the ‘new’ keyword, you can also pass the class object (e.g. ‘FirstView.class’) to the Navigator so that the view is only instantiated once the view is navigated to.