A simple Next.js API to generate SVG avatars with gradient backgrounds and customizable text. The API supports various query parameters for personalization, making it easy to use in any project.
- Dynamically generated SVG avatars with gradients.
- Customizable avatar size, text, and corner rounding.
- Powered by Next.js with support for Edge API Routes.
-
Clone the repository:
git clone https://github.com/constantimi/avatar-generator.git cd avatar-generator
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
The API will be available at
http://localhost:3000/api/avatar
.
GET /api/avatar
Parameter | Type | Description | Default |
---|---|---|---|
name |
string | Name used for generating the gradient background. | Random |
text |
string | Text displayed in the center of the avatar. | (none) |
size |
number | Size of the avatar in pixels. | 120 |
rounded |
number | Corner radius for rounding the avatar in pixels. | 0 |
-
Simple Avatar:
http://localhost:3000/api/avatar?name=Ex
-
Avatar with Custom Text:
http://localhost:3000/api/avatar?name=example&text=Ex
-
Custom Size and Rounded Corners:
http://localhost:3000/api/avatar?name=example&text=Ex&size=300&rounded=20
-
Custom Encoded Hex Colors:
http://localhost:3000/api/avatar?size=500&from=%23123553&to=%2399CCFF
Where
%23
at the beginning is the encoding of the#
symbol for the hex color.