React & React Native

Protected routes

Në shqip: Faqet e mbrojtura

ShpjegimiSQ

Një rrugë e mbrojtur shfaqet vetëm nëse përdoruesi është i kyçur; përndryshe e çon te faqja e hyrjes. Kujdes: kontrolli në frontend është vetëm për komoditet — serveri duhet ta kontrollojë gjithmonë sërish.

EnglishEN

A protected route only shows if the user is logged in; otherwise it redirects to the login page. Careful: the frontend check is only for convenience — the server must always check again.

Si ta mendosh

Si dera e zonës VIP: roja të kthen te arka nëse s'ke biletë.

Lexoje në anglisht

Like the VIP area door: the steward sends you back to the box office if you have no ticket.

Shembull kodijavascript

function EMbrojtur({ children }) {
  const { perdoruesi } = useAuth();
  return perdoruesi ? children : <Navigate to="/hyrja" replace />;
}

Terma të lidhur