Guides
Removing Internationalization
Learn how to remove internationalization from your Nextbase application
Many saas products require internalization. But many don't need it too. Ultimately it is your customer requirements that matter.
If you don't need internationalization, you can remove it by following these steps:
- Move all the children of the
src/app/[locale]
folder to thesrc/app/
folder. - Remove the
[locale]
from thesrc/app/
folder. - Remove the
next-intl
from thepackage.json
file. - Update your middleware to this pattern. Pay close attention to the
// your imports stay the same
/**
* Public paths are paths that are accessible to everyone.
* They don't require the user to be logged in.
*/
const publicPaths = [
`/`,
`/changelog`,
//... other public paths
];
/**
* Dashboard routes are paths that are accessible to logged in users.
* They require the user to be logged in.
*/
const dashboardRoutes = [
`/dashboard(/.*)?`,
// ... other dashboard routes
];
/**
* Onboarding paths are paths that are accessible to users who are not onboarded.
* They require the user to be logged in.
* However, if the user is not onboard, the dashboard routes are not accessible.
*/
const onboardingPaths = [`/onboarding(/.*)?`];
/**
* App admin paths are paths that are accessible to app admins.
* They require the user to be logged in.
*/
const appAdminPaths = [`/app_admin(/.*)?`];
/**
* All routes which require login including dashboard, onboarding and app admin.
*/
const protectedPaths = [
...dashboardRoutes,
...onboardingPaths,
...appAdminPaths,
];
type MiddlewareFunction = (request: NextRequest) => Promise<NextResponse>;
interface MiddlewareConfig {
matcher: string | string[];
middleware: MiddlewareFunction;
}
function withMaybeLocale(request: NextRequest, subPath: string) {
const currentLocale = request.cookies.get("NEXT_LOCALE")?.value;
if (currentLocale) {
return urlJoin(currentLocale, subPath);
}
return subPath;
}
const middlewares: MiddlewareConfig[] = [
// remove the first two middleware configs which are related to locale
{
// protected routes
matcher: protectedPaths, // instead of protectedPathsWithLocale
middleware: async (req) => {
// ...
},
},
{
matcher: dashboardRoutes, // instead of dashboardRoutesWithLocale
middleware: async (req) => {
// ...
},
},
{
matcher: onboardingPaths, // instead of onboardingPathsWithLocale
middleware: async (req) => {
// ...
},
},
{
// match /app_admin and /app_admin/ and all subpaths
matcher: appAdminPaths, // instead of appAdminPathsWithLocale
middleware: async (req) => {
// ...
},
},
];
// the rest of the middleware configs stay the same
- Remove
src/i18n
folder. - Replace all
import { Link } from "@/components/intl-link";
withimport Link from "next/link";
- Remove all
LocaleSwitcherSelect
component and its usage - Remove
import createNextIntlPlugin from "next-intl/plugin"
and its usage innext.config.mjs
- Remove
unstable_setRequestLocale
usage in all static pages andlocale
from 'params'. - Remove
useTranslations
usage in all client components. - Remove
getMessages
usage in root layout component and removelocale
andmessages
props fromAppProviders
component. Finally removeNextIntlProvider
from theAppProviders
component.
Optimizing Data Operations in Next.js 14 and Supabase
Learn how to efficiently fetch and mutate data in Next.js 14 and Supabase using server components, useToastMutation, and Supabase real-time APIs.
Row Level Security
Row Level Security in NextBase is a powerful feature that allows you to control access to rows in your database based on the user who is querying the data.