<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged adminforth</title>
<link>https://coderlegion.com/tag/adminforth</link>
<description>Powered by Question2Answer</description>
<item>
<title>How to create admin panel in a minutes</title>
<link>https://coderlegion.com/3028/how-to-create-admin-panel-in-a-minutes</link>
<description>&lt;p&gt;I will show you how to easily create an extendable admin panel using the open-source (and free!) AdminForth framework. The setup process is incredibly simple and takes just a few minutes.&lt;/p&gt;
&lt;h3 id=&quot;requirements&quot;&gt;Requirements&lt;/h3&gt;
&lt;p&gt;All you need is Node.js version 20 or later installed.&lt;/p&gt;
&lt;h3 id=&quot;let-s-get-started&quot;&gt;Let's get started&lt;/h3&gt;
&lt;p&gt;Run:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;npx adminforth create-app
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will launch a small utility that will ask you to name your project.&lt;br&gt;
Then, it will prompt you for your database URL in the field &lt;code&gt;&quot;Please specify the database URL to use &amp;gt;&quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can use SQLite, Postgres, MySQL, MongoDB, or ClickHouse URLs.&lt;br&gt;
For testing purposes, we recommend SQLite, as it doesn't require a daemon and works out of the box.&lt;/p&gt;
&lt;p&gt;Once the app is created, you should see:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=1577179538893905645&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h3 id=&quot;next-steps-prepare-and-run-the-app&quot;&gt;Next steps: prepare and run the app&lt;/h3&gt;
&lt;p&gt;Run the suggested commands:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd adminforth-app
npm run makemigration -- --name init &amp;amp;&amp;amp; npm run migrate:local
npm run dev
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That's it! Open &lt;a rel=&quot;nofollow&quot; href=&quot;http://localhost:3500/&quot;&gt;http://localhost:3500/&lt;/a&gt; in your browser and you should see:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=7207669731169366153&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Login using &lt;code&gt;adminforth&lt;/code&gt; as both username and password.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;⚠️ In production, be sure to change the password for this user via the admin panel.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You will now see a list of admin users:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=18199405401752693134&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Try adding a user, and you can also test logging in with that user from an incognito window.&lt;br&gt;
Feel free to play around — try filters, navigation, and more.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;how-to-add-a-table-to-adminforth-admin-&quot;&gt;How to add a table to AdminForth Admin?&lt;/h2&gt;
&lt;p&gt;Now comes the most exciting part.&lt;br&gt;
By now, Prisma has generated a migration for the initial &lt;code&gt;adminuser&lt;/code&gt; table. But what if you want to manage additional tables from your existing database or add new ones? Let's do that.&lt;/p&gt;
&lt;p&gt;Let's add a new table to our SQLite database. Open your project in VS Code / Cursor:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;code .
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=8094413108377506425&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now, add the following code to your Prisma schema:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;model car {
  id            String   @id
  title         String
  max_speed     Int
  preview       String?   
  price         Decimal
  currency      String
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create and apply the migration:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;npm run makemigration -- --name add_car_model &amp;amp;&amp;amp; npm run migrate:local
&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;&lt;p&gt; AdminForth is migration-agnostic — it never manages your database schema itself and can work with any database structure.&lt;br&gt;
For quick-start and testing purposes, the app created via &lt;code&gt;adminforth create-app&lt;/code&gt; bundles Prisma, which we used here for our SQLite schema.&lt;br&gt;
However, you're free to use any migration tool for your database. All AdminForth needs to know is the table and field names for the next step.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
&lt;h3 id=&quot;define-the-resource&quot;&gt;Define the resource&lt;/h3&gt;
&lt;p&gt;Create a new resource file in the &lt;code&gt;resources&lt;/code&gt; folder named &lt;code&gt;car.ts&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { AdminForthDataTypes, AdminForthResourceInput } from &quot;adminforth&quot;;
import { randomUUID } from &quot;crypto&quot;;


export default {
  table: &quot;car&quot;,
  resourceId: &quot;car&quot;,
  dataSource: &quot;maindb&quot;,
  columns: [
    {
      name: &quot;id&quot;,
      fillOnCreate: () =&amp;gt; randomUUID(),  // generate a random UUID when creating a new record in admin
      showIn: {
        create: false,
        list: false,
      }
    },
    {
      name: &quot;title&quot;,
      type: AdminForthDataTypes.STRING, // enforce STRING type (SQLite supports only TEXT, this ensures single-line input)
    },
    {
      name: &quot;max_speed&quot;,
      inputSuffix: &quot;km/h&quot;, // add a suffix in create/edit forms
    },
    {
      name: &quot;preview&quot;,
    },
    {
      name: &quot;price&quot;,
    },
    {
      name: &quot;currency&quot;,
      enum: [  // define an enumeration — AdminForth will automatically create a dropdown
        {
          label: &quot;Bitcoin&quot;,
          value: &quot;BTC&quot;,
        },
        {
          label: &quot;Tether&quot;,
          value: &quot;USDT&quot;,
        },
      ]
    }
  ]
} as AdminForthResourceInput;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now import this resource into &lt;code&gt;index.ts&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import carsResource from &quot;./resources/car.js&quot;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And add it to the &lt;code&gt;resources&lt;/code&gt; list so AdminForth will know about it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  resources: [
    usersResource,
    carsResource, // added here
  ],
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, let's add a menu item so you can access the resource from the UI:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  menu: [
    { type: 'heading', label: 'SYSTEM' },
    {
      label: 'Users',
      icon: 'flowbite:user-solid',
      resourceId: 'adminuser'
    },
    // added this
    {
      label: 'Cars',
      icon: 'fa6-solid:car-side',
      resourceId: 'car'
    }
  ],
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And you're done!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://coderlegion.com/?qa=blob&amp;amp;qa_blobid=4676291766370977265&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Play around by adding your favorite cars and try filtering them.&lt;br&gt;
That's it for today! If you enjoyed this, feel free to leave a comment or reaction.&lt;br&gt;
Let me know if you'd like me to create more posts about extending and scaling your admin panel, adding powerful features like audit logs, file uploads, Google login, password reset, CSV import/export, and much more.&lt;/p&gt;
&lt;p&gt;I’m looking forward to your reactions! &lt;/p&gt;
</description>
<category>Getting Started</category>
<guid isPermaLink="true">https://coderlegion.com/3028/how-to-create-admin-panel-in-a-minutes</guid>
<pubDate>Wed, 14 May 2025 20:48:42 +0000</pubDate>
</item>
</channel>
</rss>