What is Dancer?

Dancer is a simple but powerful web application framework for Perl.

Key features

  • Dead Simple - Intuitive, minimalist and very expressive syntax.
  • Flexible - PSGI support, plugins and modular design allow for strong scalability.
  • Few dependencies - Dancer depends on as few CPAN modules as possible making it easy to install.

Prepare your moves... and dance!

Dancer has been designed as a Perl web framework which is easy and intuitive to get to grips with:

  •     #!/usr/bin/env perl
        use Dancer2;
        get '/' => sub {
            "Hello World!"
  •     $ plackup bin/app.psgi &
        $ curl https://localhost:5000/
        Hello world!

Getting started with Dancer is easy, yet it provides everything you need to write your web applications with ease!

Wide template support

Dancer can be used with a wide variety of templating systems, including:

    • Template Toolkit
    • Template::Flute
    • HTML::Template
    • Template::Tiny
    • Mason
    • Template::Alloy
    • HTML::CTPP2
    • Tenjin
    • Text::Haml
    • Text::Caml
    • Mojo::Template
    • Template::Declare

Support for many more template engines is available, and it's easy to write a Dancer2::Template::* wrapper to add support for your favourite engine if it's not already available.

Easy database interaction

If you're using a Perl web framework, you want the easy stuff taken care of for you, so you can write the interesting stuff. The same applies to database access - it should be simple and non-tedious.

ORM with DBIx::Class

Dancer2::Plugin::DBIC provides easy database access using DBIx::Class:

get '/profile/:id' => sub {
    my $user = schema->resultset('Users')->find(params->{id});

Or easy DBI database access

Dancer2::Plugin::Database manages your database connections, providing an augmented DBI database handle for you to use:

get '/profile/:id' => sub {
    my $user = database->quick_select('Users', { id => $params->{id} });

Either way, we've got you covered.

Automatic serialisation for AJAX/APIs

Just enable one of the built-in seralizers and any references your routes return will automatically be serialised to JSON, XML, YAML - whatever you need. Use the Mutable serializer and the format can even be selected by the user making the request based on an "Accept" HTTP header.

ajax '/getloadavg' => sub {
    return {
        timestamp => time(),
        loadavg   => ( Unix::Uptime->load )[0],

The above example simply returns a hashref from the route handler; the serializer takes care of turning it into the desired format (e.g. JSON) and returning it to the user.

(The example comes from the Dynamic AJAX charting with Dancer 2011 Advent Calendar post.)

Easy session support

Session support is in-built, with a wide choice of session storage methods:

  • YAML/JSON/Storable files on disc
  • Memcached
  • DBI
  • MongoDB
  • Redis
  • Encrypted cookies
  • DBIx::Class

Extensible with plugins and engines

There's a wide range of plugins available on CPAN to provide useful extra features to make writing your applications even eaiser, and support for a wide range of template engines, logging methods, session storage methods, serialisers...

Just search CPAN and see!

What people say about Dancer...

Its damn quick to develop, its quick to run, even a colleague who is helping do the templating (and a php developer) is converted! - Zahir Lalani

@PerlDancer Excellent framework! Thank you for making it easy for guys like me with two left feet who have to dance to make a living. - Rahul Kotamaraju (@rahul_k_v_)

We needed to move really fast and provide a highly scalable, extensible, and maintainable product to our customers to enable them to pool money together. Using Perl Dancer and CPAN, we were able to prototype our site in a couple of days. That same “protoype” has evolved to the current version of the website over just a few weeks. - CrowdTilt

@PerlDancer is probably the coolest framework I've used this year! - Miguel (@miguelcnf)

Forgot to mention @twitpardy's backend is written in #Perl and website uses #Dancer. Props to the @perldancer team for the AWESOME software! - Mike (@mrpants)

Dancer2 seemed to really stand out [...] After a couple of weeks I have the beginnings of a complex web app which is n+1 scaleable, which has a REST API module and will also have a messaging and workflow tool with a video render farm - all done in a single language and framework. - Zahir Lalani

Dancer web framework is all about making simple things fun, and complex things possible. If you're into web development, make sure not to skip Dancer! [...] The team behind the project is very friendly and willing to help beginners to get up to speed. - Tyler Durden

Web development is fun again thanks to Dancer. I spend less time breaking things and more time solving problems. More time getting to the fun part of coding. - Joshua Keroes

It's fast! It's simple! It's minimalistic! I really like it! Thanks. - Łukasz Metys Lewandowski

I believe so much in Dancer that I've given talks about it at local Perl Monger's groups, have taught a few people how to use it, and have even built my next generation web services framework at Plain Black on top of it. - JT Smith @ The Game Crafter

Dancer is the first web framework I haven't wanted to pee on :-) - Schwern

Formerly a Perl teacher, I never taught web development to the first-year students because the learning curve would have been too steep. I think Dancer has changed the game and beginners *can* learn Perl web development using Dancer. - Andrew Soloman

Of all the light-weight frameworks, Dancer was the nicest to work with when I went through to evaluate them... - Daniel Pittman

I loved the simplicity and straight-forwardness of Dancer. It's so dead-simple and just gets out of your way. At a startup, you just want to pick tools that let you hit the ground running, and Dancer definitely gave us that. - Will Wolf @ Crowdtilt

I like how dancer doesn't force you to code in any specific way, it provides the right amount of syntactic sugar to get your app up and running in double quick time - but doesn't get in the way when you want to do something else. It's nice and light, and can be deployed in many environments. Thumbs up from me! - James Aitken

I’m really enjoying using Perl’s Dancer for building lightweight web applications. It’s heavily inspired by Ruby’s Sinatra framework, but clearly Perlish. - Joshua Barratt

Dancer is a breath of fresh air in the convoluted world of Perl web frameworks. I have a lot vested in CGI::Application, another fine framework, but Dancer has really caught my fancy for future web apps. - punkish

Check out Perl Dancer as a web framework for example and you'll see simplicity. - knighthacker on HN

Dancer2 is just amazing - the number of add-on modules is great and I can get on with the application without worrying about the nitty gritty. - Zahir Lalani

The Dancer community has always been responsive to us when we've had questions, or pull requests, or issues. That's really important in any software project or piece of technology you use. - Will Wolf @ Crowdtilt

Dancer is the first web framework that hasn't given me an aneurysm. #perl - Michael G Schwern (@schwern)

Dancer is incredibly easy to learn, yet very powerful. Dancer is THE fastest way to develop web applications, hands down. - Rob Boerman

Hacking around using @PerlDancer and enjoying it immensely. - deepakg

...there's finally a web framework that works for me. It's called Dancer, and as redundant as this might sound; Dancer, is an effortless web framework. [...] It took me more time studying Dancer's features and specs, than the time it took for me to write the whole mini-blog app. - Carlos Ivan Sosa (gnusosa)

...everyone I've shown the codebase to can't believe how tiny everything is. You need to write so little code to do so much. - JT Smith @ The Game Crafter

The heavy hitters are Catalyst, Mojolicious, and Dancer. Any one of them can be used to build a large-scale web application just as easily as Django in Python, or Ruby on Rails. - Christopher Cashell

@PerlDancer is the easiest way to write webapps. One day from idea to implemention. Fantastic work. - alexkalderimis

Just wrapped up an eight hour scrum task in 90 minutes. I'm really enjoying using Dancer. Awesome, awesome, awesome! - talexb

Trying out @PerlDancer as a basis for building web apps. Very nice. - talexb

In the end I went with Dancer and I'm loving it so far - some more docs on the idiomatic way to deal with user creation, authentication and roles might be nice but I think I figured it all out pretty quickly. - Simon Wistow

I have - and would second frameworks like Perl Dancer as fantastic examples of what the Perl community is up to these days. - corn on Hacker News

Working on Perl Dancer and Extjs, wow, now programming is fun again! - James Michael DuPont (@h4ck3rm1k3)

Perl is [...] thriving and making some very cool new stuff while steadily negating the argument of being line-noise (Dancer comes to mind as an excellent project to both read and use). - dragonquest on Hacker News

Just downloaded and ran #Perl Dancer. Really curious about it. It looks amazing. - @juliofraire

Perl Dancer is amazing! If you're into web development, definitely give Dancer a look, you might be surprised how fun and productive web development can be these days. Dancer is two things packed together: it stays out of your way if you like that, but also provides you with very powerful primitives to get the complex web tasks done in just a few lines of code. Highly recommended to both novices and experts! - linportal on reddit

For a simple framework I suggest Dancer. Great thing, it made me stop hating web development. - tsjr

I just spent yesterday with Perl Dancer and was able to get a website going for my Dad's software consulting company in no time at all! Thanks for all your efforts on Dancer it is pretty awesome. - Bryon Wickland

[...] the words that come to mind are "quick", "small", "simple" and "clean". There's a close alignment of the packages and methods with the concepts one has in mind when doing web development. Formerly a Perl teacher, I never taught web development to the first-year students because the learning curve would have been too steep. I think Dancer has changed the game and beginners *can* learn Perl web development using Dancer. (We'll find out at the beginner's class I'm giving at YAPC in Riga:) - Andrew Solomon on cpanratings

I say I spent the afternoon on it, but @perldancer makes web dev so simple that it actually took about an hour. - Dave Cross (@davorg)

Got my webservice up and running in 1 day with no knowledge about Dancer whatsover.[...] Dancer is excellent for middle size websites or web services. It doesn't get in your way, and supports a [...] lot of backend for deploying and running your application. The transition from developing a prototype to having a production ready app is very smooth. - Damian Krotkine

Thanks to the @PerlDancer guys in IRC for their help.. better than any commercial support IMO - John Imison (@johnimison)

When I picked Dancer I wasn't looking for a tool that did everything for me out of the box. I was looking for something I could grow into and build the app the way I wanted to build it. Dancer is easily extensible without getting in my way or limiting me, and that's a big win. - JT Smith @ The Game Crafter

Fork me on GitHub