In this work, we adapt a module for planetary formation within the hydrodynamic code FARGO3D. Planetary formation is modeled by a solid core accretion scenario, with the core growing in oligarchic regime. The initial superficial density of planetesimals is proportional to the initial superficial density of gas in the disc. We include a numerical approach to describe the evolution of the eccentricity and the inclination of planetesimals during the formation. This approach impacts directly on the accretion rate of solids. When the core reaches a critical mass, gas accretion begins, following the original FARGO scheme adapted to the FARGO3D code. To exemplify how the module for planetary formation can be used, we investigate the migration of a planet in a two-dimensional, locally isothermal gas disc with a prescribed accretion rate, analyzing the timescale involved in the planetary migration process along with the timescale for planetary formation. The analysis reveals that the mass of the nucleus must be close to its critical value when crossing the ice line to avoid the planet's fall into the stellar envelope. This will allow enough time for the planet to initiate runaway gas accretion, leading to a rapid mass increase and entering type II planetary migration.