OPINION
TERRY JENNINGS, Justice.Relator, R.G., challenges the juvenile court’s order vacating its previous order granting him habeas corpus relief and a new trial on the court’s adjudication of his delinquency. In his sole issue, relator contends that the juvenile court erred in va-eating its order granting him habeas corpus relief on the ground that it did not have jurisdiction to grant the relief. Relator also contends that the juvenile court “lacked plenary power” to set aside its order granting him habeas corpus relief.
We conditionally grant the writ of mandamus.
Background
On March 20, 1995, a jury found that relator, who was fourteen years old at the time, engaged in delinquent conduct,1 namely, committing the offense of murder,2 and assessed his punishment at confinement for forty years. The Fourteenth Court of Appeals affirmed the adjudication of delinquency. In re R.G., No. 14-95-00584-CV, 1997 WL 379151 (Tex.App.Houston [14th Dist.] July 10, 1997, pet. denied) (not designated for publication).
On August 4, 2009, relator filed, in the juvenile court, an application for a writ of habeas corpus, alleging that he was denied effective assistance of counsel during his adjudication. On January 28, 2011, after a hearing, the juvenile court found that relator’s adjudication was “based on the admission of inadmissible testimony, improper questions, argument outside the record, and ineffective assistance of counsel.” Accordingly, it granted relator habeas corpus relief and a new trial.
Six months later, on June 28, 2011, relator filed a motion to dismiss the case against him for lack of jurisdiction. He asserted that the juvenile court lacked jurisdiction to retry him after he had become 17 years of age. The State responded, arguing that the juvenile court retained continuing jurisdiction over relator to retry his adjudication of guilt. After a hear*822ing on the motion to dismiss, the juvenile court concluded that it had “no jurisdiction to re-try [the] case,” further stating that “it appears this Court lacked jurisdiction to consider [relator’s] habeas corpus or grant a new trial.” The juvenile court then vacated its order granting relator habeas relief and a new trial, and it reinstated relator’s adjudication of delinquency-
Appellate Jurisdiction
At the - outset, we note that the State argues that this Court does not have jurisdiction to hear this “appeal” because it not authorized by the Texas Family Code. See Tex. Fam. Code Ann. § 56.01(c)(1) (Vernon Supp. 2011). Section 56.01(c)(1) provides that an appeal may be taken “by or on behalf of a child” from an order entered under:
(A) Section 54.03 with regard to delinquent conduct or conduct indicating a need for supervision;
(B) Section 54.04 disposing of the case;
(C) Section 54.05 respecting modification of a previous juvenile court disposition; or
(D) Chapter 55 by a juvenile court committing a child to a facility for the mentally ill or mentally retarded....
Id. Moreover, an appeal may be taken “by a person from an order entered under Section 54.11(i)(2) transferring the person to the custody of the Texas Department of Criminal Justice.” Id. § 56.01(c)(2). The State argues that because this “appeal” does not fall into any of the above categories, this Court must dismiss the appeal for lack of jurisdiction. However, section 56.01 also provides that it “does not limit a child’s right to obtain a writ of habeas corpus.” Id. § 56.01 (o).
The State correctly notes that in criminal cases, “no appeal can be had from a refusal to issue or grant a writ of habeas corpus even after a hearing.” See Ex Parte Hargett, 819 S.W.2d 866, 868 (Tex.Crim.App.1991). However, “[w]hen a hearing is held on the merits of an applicant’s claim and the court subsequently rules on the merits of that claim, the losing party may appeal.” Id. Regardless, in its order vacating its grant of habeas corpus relief, the juvenile court did not purport to deny relator’s relief on the merits. Rather, relator is now in the position of arguing that the juvenile court erred in issuing the order vacating its order granting habeas corpus relief because it had jurisdiction to grant him the relief and the order vacating the granting of relief is void because the juvenile court issued it after its plenary power had expired. Mandamus relief is appropriate when a trial court issues an order after its plenary power has expired because that order is void. In re Brookshire Grocery Co., 250 S.W.3d 66, 68-69 (Tex.2008) (orig. proceeding); In re Office of the Attorney Gen. of Tex., 264 S.W.3d 800, 805 (Tex.App.-Houston [1st Dist.] 2008) (orig. proceeding).
Relator requests that, if this Court concludes that it does not have appellate jurisdiction, we construe his appeal as a petition for a writ of mandamus. The Texas Supreme Court recently held that an interlocutory appeal should not have been dismissed for lack of jurisdiction, but instead should have been considered as a petition for a writ of mandamus as requested by the petitioner. CMH Homes v. Perez, 340 S.W.3d 444, 453-54 (Tex.2011). The court explained that “Texas policy ... ‘disfavors disposing of appeals based upon harmless procedural defects.’ ” Id. at 453 (quoting Higgins v. Randall County Sheriff’s Office, 257 S.W.3d 684, 688 (Tex.2008)); see also In re J.P.L., 359 S.W.3d 695, 703 (Tex.App.-San Antonio 2011, pet. filed) (construing appeal from nonfinal order *823granting petition to enforce child custody as request for writ of mandamus). Accordingly, we construe relator’s briefing as a petition for writ of mandamus.
Standard of Review
Mandamus is an extraordinary remedy, which is available only when (1) a trial court clearly abuses its discretion and (2) there is no adequate remedy by appeal. In re Prudential Ins. Co. of Am., 148 S.W.3d 124, 135-36 (Tex.2004). A trial court clearly abuses its discretion if it reaches a decision so arbitrary and unreasonable as to amount to a clear and prejudicial error of law. Walker v. Packer, 827 S.W.2d 833, 839 (Tex.1992). With respect to a trial court’s determination of legal principles, “a trial court has no ‘discretion’ in determining what the law is or applying the law to facts.” In re Prudential, 148 S.W.3d at 135 (quoting Walker, 827 S.W.2d at 840).
Juvenile Court’s Jurisdiction
In his sole issue, relator argues that the juvenile court erred in vacating its order granting him habeas corpus relief because it did have jurisdiction to grant him the relief and it vacated the order granting him relief after its plenary power had expired.
Subject-Matter Jurisdiction
Whether a trial court has subject-matter jurisdiction is a question of law that we review de novo. Westbrook v. Penley, 231 S.W.3d 389, 394 (Tex.2007).
Here, the juvenile court, the 315th Judicial District Court of Harris County, is a “family district court.” Tex. Gov’t Code Ann. §§ 24.601, 24.623 (Vernon 2004). “A family district court has the jurisdiction and power provided for district courts by the constitution and laws of this state.” Id. § 24.601(a). “Its jurisdiction is concurrent with that of other district courts in the county in which it is located.” Id. The Texas Constitution confers to the district courts “exclusive, appellate, and original jurisdiction of all actions, proceedings, and remedies, except in cases where exclusive, appellate, or original jurisdiction may be conferred by this Constitution or other law on some other court, tribunal, or administrative body.” Tex. Const, art. 5, § 8. And district court judges “shall have the power to issue writs necessary to enforce their jurisdiction.” Id.
The Family Code provides that “[i]n each county, the county’s juvenile board shall designate one or more district, criminal district, domestic relations, juvenile, or county courts or county courts at law as the juvenile court.” Tex. Fam. Code Ann. § 51.04(b) (Vernon 2008). The 315th Judicial District Court has been designated as a juvenile court. See Harris County District Judges Rules of Administration R. 9.1.3 (listing 315th Judicial District Court as one of three courts constituting Harris County’s “juvenile division” as established “by statutory preferences and board policy”). The Juvenile Justice Code covers the proceedings “in all cases involving the delinquent conduct ... engaged in by a person who was a child within the meaning of this title at the time the person engaged in the conduct.” Tex. Fam. Code Ann. § 51.04(a). “[T]he juvenile court has exclusive original jurisdiction over proceedings under” the Juvenile Justice Code. Id.
The State argues that relator failed to invoke the constitutional jurisdiction of the juvenile court as a “district court” because he filed his application for a writ of habeas corpus “under the same petition number as the murder petition and directed it to the same court,” which, the State asserts, made the petition effectively an out-of-time motion for new trial. The State further asserts that relator invoked the juvenile *824court’s “limited jurisdiction solely as a juvenile court,” which lacked the subject-matter jurisdiction to consider the writ. In support of this proposition, the State, as did the juvenile court in vacating its order, relies on In re N.J.A., 997 S.W.2d 554 (Tex.1999). In In re N.J.A., a juvenile defendant turned eighteen years of age during the pendency of a petition to transfer the case to criminal district court, which was denied. Id. at 554-55. The Texas Supreme Court held that the juvenile court no longer had jurisdiction to adjudicate the defendant’s guilt. Id. at 556-57. The court reasoned that “[ljogically, once a juvenile becomes eighteen, the juvenile court’s jurisdiction does not include the authority to adjudicate the juvenile.” Id. at 555. It held that once a juvenile defendant turns eighteen, the juvenile court’s jurisdiction is limited to waiving its exclusive jurisdiction and transferring the case to district court, providing certain criteria are met. Id. at 557 (citing Tex. Fam. Code Ann. 54.02(j) (Vernon Supp. 2011)).3
Although relator filed his application for a writ of habeas corpus under the same cause number as that used in the previous juvenile proceedings, he styled it as an “Application for Writ of Habeas Corpus,” alleging that he was denied effective assistance of counsel at his trial. In his application, relator argued that the juvenile court had jurisdiction, pursuant to the Texas Constitution, to consider a writ of habeas corpus. The State, and the juvenile court, treated relator’s pleading as an application for a writ of habeas corpus during every stage of the proceedings. The court referred to it as an application for a writ of habeas corpus in its order granting relief and in its order vacating relief, noting that relator filed his application “pursuant to Article 5, Section 8 of the Texas Constitution.” Thus, despite filing his application under the same cause number as that used in the previous juvenile proceedings, relator actually filed an application for a writ of habeas corpus, and he invoked the constitutional jurisdiction of the juvenile court, as a district court, to consider such writs. See Tex. Const, art. 5, § 8; In re Hall, 286 S.W.3d 925, 926-27 (Tex.2009) (recognizing civil district court, which was also juvenile court, had jurisdiction to hear writ of habeas corpus); Ex Parte Valle, 104 S.W.3d 888, 889-90 (Tex.Crim.App.2003) (holding that civil, not criminal, district courts should entertain writs of habeas corpus, and noting that “several courts of appeals have entertained appeals when writs of habeas corpus were issued by district courts on the application of juveniles accused of delinquent conduct”). Accordingly, we hold that the juvenile court had jurisdiction to entertain relator’s application for a writ of habeas corpus pursuant to its constitutional jurisdiction as a district court.
Plenary Power
Relator next argues that the juvenile court lacked the power to vacate its *825order granting him habeas corpus relief because a trial court has plenary power to grant a new trial or to vacate, modify, correct, or reform a judgment “within thirty days after the judgment is signed.” See Tex. R. Civ. P. 329b(d). Relator further argues that because the juvenile court’s order vacating its grant of habeas corpus relief was entered more than thirty days after the original order, it acted outside of its plenary power to modify the original order.
The State argues that relator’s application is in effect an out-of-time motion for new trial. See In re Baylor Med. Ctr. at Garland, 280 S.W.3d 227 (Tex.2008). In Baylor, a trial court vacated a previous order granting a motion for new trial two months after it had granted the new trial, reinstating the original jury verdict. Id. at 228-29. The Texas Supreme Court explained that once a new trial is timely granted, “the case stands on the trial court’s docket ‘the same as though no trial had been had.’ ” Id. at 230-31 (citing Wilkins v. Methodist Health Care Sys., 160 S.W.3d 559, 563 (Tex.2005)). The court noted that federal courts and commentators have observed that , there is “no sound reason why the court may not reconsider its ruling [granting] a new trial” at any time. Id. at 232 (citing 6A James William Moore, Moore’s Federal Practice 1159.13[1], at 59-227 (2d ed. 1996)). Ultimately, the court concluded that a trial court should “have the power to set aside a new trial order ‘any time before a final judgment is entered.’ ” Id. at 231 (quoting Fruehauf Corp. v. Carrillo, 848 S.W.2d 83, 84 (Tex.1993)).
The State argues that we should apply the above rule to the instant case because the Texas Family Code provides that, except as otherwise provided, “the Texas Rules of Civil Procedure govern proceedings under” the Juvenile Justice Code and courts have stated that juvenile proceedings are “civil in nature.” See Tex. Fam. Code Ann. § 51.17(a) (Vernon Supp. 2011); Ex Parte Valle, 104 S.W.3d at 890. However, relator’s application, styled as a petition for a writ of habeas corpus, initiated an entirely new proceeding; it cannot be treated as a motion for new trial in the underlying juvenile adjudication proceeding, which was disposed of by a final judgment entered long ago.
As the State itself notes, an application for a writ of habeas corpus constitutes a “separate proceeding collaterally attacking” the original judgment. See, e.g., Ex Parte Rieck, 144 S.W.3d 510, 516 (Tex.Crim.App.2004) (recognizing that habeas proceedings are considered to be “separate from the criminal prosecution”); Rose v. State, 198 S.W.3d 271, 272 (Tex.App.-San Antonio 2006, pet. ref d) (“A ha-beas corpus proceeding, unlike a criminal trial, is an independent proceeding that makes inquiry into the validity of the conviction .... ”). “An application for habeas corpus is not like a motion for new trial in the sense that a habeas proceeding is not part of the underlying criminal prosecution against the applicant.” Ex Parte Cummins, 169 S.W.3d 752, 757 (Tex.App.-Fort Worth 2005, no pet.); see also Ex Parte Calvan-Herrera, No. 13-11-00380-CR, 2012 WL 1484097, at *4-5 (Tex.App.-Corpus Christi Apr. 26, 2012, pet. struck) (mem. op.) (holding that application for writ of habeas corpus was not governed by rules applicable to motion for new trial because those rules “govern[] only direct challenges to a defendant’s conviction or punishment filed within thirty days”).
Thus, the granting of an application for a writ of habeas corpus where one is collaterally attacking a judgment is fundamentally different from the granting of a motion for new trial, where one is directly and timely attacking a judgment. In In re *826Baylor, the Texas Supreme Court reasoned that the granting of a timely filed new-trial motion may be reconsidered by the trial court at any time because a trial court has “not only the authority but the responsibility to review any pre-trial order upon proper motion.” 280 S.W.3d at 231 (citing Downer v. Aquamarine Operators, Inc., 701 S.W.2d 238, 241 (Tex.1986)). The granting of habeas corpus relief, in a separate and distinct proceeding from the original proceeding, and from which the State is entitled to appeal in certain circumstances,4 cannot be characterized as a “pre-trial” order.
Here, the juvenile court entered its order granting relator habeas corpus relief on January 28, 2011, and the State did not appeal from or otherwise complain about that order. And, as stated above, the juvenile court had jurisdiction to grant relator’s application for a writ of habeas corpus pursuant to its constitutional jurisdiction as a district court. Accordingly, we hold that the juvenile court abused its discretion and exceeded its plenary power when it vacated its order granting relator habeas corpus relief more than six months after granting the relief. Thus, its order vacating relief is void. See Tex. R. Crv. P. 329b(d) (providing that trial court has plenary power to vacate or modify its judgment within thirty days after it is signed); In re State ex rel. Sistrunk, 142 S.W.3d 497, 503 (Tex.App.Houston [14th Dist.] 2004, no pet.) (noting that trial court generally retains plenary jurisdiction over case for thirty days after sentencing).
We sustain relator’s sole issue.
Conclusion
We conditionally grant the writ of mandamus and reverse the juvenile court’s order vacating its order granting habeas corpus relief, and we reinstate the juvenile court’s order granting relator a new trial. The writ will issue only if the trial court fails to comply.
. See Tex Fam. Code Ann. § 51.03 (Vernon Supp. 2011).
. See Tex. Penal Code Ann. § 19.02 (Vernon 2011).
. We note that during R.G.'s incarceration, the Texas Legislature provided an exception to the holding of In re N.J.A. See Tex Fam. Code Ann. § 51.0412 (Vernon Supp. 2011); see also In re V.A., 140 S.W.3d 858, 859 (Tex.App.-Fort Worth, no pet.). Section 51.0412 provides that a juvenile court retains jurisdiction over a person, "without regard to the age of the person,” if the original petition was filed before the person turned 18 years of age, the proceeding is not complete before the person turned 18 years of age, and the juvenile court enters a finding that the prosecuting attorney exercised due diligence in an attempt to complete the proceedings before the person turned 18 years of age. Tex. Fam. Code Ann. § 51.0412. However, section 51.0412 does not apply “to conduct that occurred] on or after the effective date,” which was September 1, 2001. See Act of Sept. 1, 2001, 77th Leg., R.S., ch. 1297, § 72, 2001 Tex. Gen. Laws 3142, 3175.
.. See, e.g., State v. Nkwocha, 31 S.W.3d 817, 818 n. 1 (Tex.App.-Dallas 2000, no pet.) (noting that State could appeal grant of habeas corpus relief, ordering new trial, on grounds of newly-discovered evidence); State v. Kana-pa, 778 S.W.2d 592, 593 (Tex.App.-Houston [1st Dist.] 1989, no pet.) (noting that State can appeal from habeas corpus proceeding when it would otherwise have right to appeal under Code of Criminal Procedure).