The present invention relates to imidazole and pyrazine compound and its preparation method and application. The preparation is used to reduce or inhibit bruton tyrosine kinase activity in cells.