4.1.0 • Published 3 days ago

@premieroctet/next-admin v4.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 days ago

Next Admin

License Version

next-admin provides a customizable and turnkey admin dashboard for applications built with Next.js and powered by the Prisma ORM. It aims to simplify the development process by providing a turnkey admin system that can be easily integrated into your project.

https://next-admin.js.org

Features

  • 💅 Customizable admin dashboard
  • 💽 Database relationships management
  • 👩🏻‍💻 User management (CRUD operations)
  • 🎨 Dashboard widgets and customizable panels
  • ⚛️ Integration with Prisma ORM
  • 👔 Customizable list and form
  • ⚙️ Supports App Router and Page Router

Installation

To install the library, run the following command:

yarn add @premieroctet/next-admin prisma-json-schema-generator

Documentation

For detailed documentation, please refer to the documentation.

Usage

To use the library in your Next.js application, follow these steps:

  1. Create an admin route in your Next.js application.
  2. Add the file [[...nextadmin]].js to the pages/admin directory.
  3. Export the NextAdmin component from the file.
  4. Use getServerSideProps to pass the props from the nextAdminRouter to the NextAdmin component.

Bonus: Customize the admin dashboard by passing the NextAdminOptions options to the router and customize the admin dashboard by passing dashboard props to NextAdmin component. (More details in the documentation)

Example

Here's a basic example of how to use the library:

App router

// app/admin/[[...nextadmin]]/page.tsx
import { NextAdmin } from "@premieroctet/next-admin";
import { getPropsFromParams } from "@premieroctet/next-admin/dist/appRouter";
import "@premieroctet/next-admin/dist/styles.css";
import Dashboard from "../../../components/Dashboard";
import { options } from "../../../options";
import { prisma } from "../../../prisma";
import schema from "../../../prisma/json-schema/json-schema.json"; // generated by prisma-json-schema-generator on yarn run prisma generate
import "../../../styles.css";
import { submitFormAction } from "../../../actions/nextadmin";

export default async function AdminPage({
  params,
  searchParams,
}: {
  params: { [key: string]: string[] };
  searchParams: { [key: string]: string | string[] | undefined } | undefined;
}) {
  const props = await getPropsFromParams({
    params: params.nextadmin,
    searchParams,
    options,
    prisma,
    schema,
    action: submitFormAction,
  });

  return <NextAdmin {...props} dashboard={Dashboard} />;
}

Page Router

import { PrismaClient } from "@prisma/client";
import schema from "./../../../prisma/json-schema/json-schema.json"; // generated by prisma-json-schema-generator on yarn run prisma generate
import "@premieroctet/next-admin/dist/styles.css";
import {
  AdminComponentProps,
  NextAdmin,
  NextAdminOptions,
} from "@premieroctet/next-admin";

const prisma = new PrismaClient();

export default function Admin(props: AdminComponentProps) {
  return <NextAdmin {...props} />;
}

export const getServerSideProps: GetServerSideProps = async ({ req, res }) => {
  const { nextAdminRouter } = await import(
    "@premieroctet/next-admin/dist/router"
  );

  const adminRouter = await nextAdminRouter(prisma, schema);
  return adminRouter.run(req, res) as Promise<
    GetServerSidePropsResult<{ [key: string]: any }>
  >;
};

Demonstration

You can find the library code in the next-admin repository.

Also you can find a deployed version of the library here.

License

This library is open source and released under the MIT License.

4.1.0

3 days ago

4.0.0

17 days ago

3.6.1

18 days ago

3.6.0

1 month ago

3.5.3

1 month ago

3.5.2

1 month ago

3.5.1

1 month ago

3.5.0

1 month ago

3.4.0

2 months ago

3.3.1

2 months ago

3.3.0

2 months ago

3.2.7

2 months ago

3.2.6

3 months ago

3.2.5

3 months ago

3.2.4

3 months ago

3.2.3

3 months ago

3.2.2

3 months ago

3.2.1

4 months ago

3.2.0

4 months ago

3.1.2

4 months ago

3.1.1

4 months ago

3.1.0

4 months ago

3.0.1

5 months ago

1.3.7

9 months ago

1.3.6

9 months ago

1.3.5

9 months ago

3.0.0

5 months ago

1.4.0

8 months ago

1.3.8

9 months ago

2.0.0

5 months ago

1.3.4

10 months ago

1.3.3

10 months ago

1.3.2

11 months ago

1.3.1

11 months ago

1.3.0

11 months ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

0.0.0

1 year ago